Skip to content

Instantly share code, notes, and snippets.

@satbirdd
Last active December 25, 2015 08:19
Show Gist options
  • Save satbirdd/6945775 to your computer and use it in GitHub Desktop.
Save satbirdd/6945775 to your computer and use it in GitHub Desktop.
sendmessage
var index = 1;
function sendMessage() {
var room_name = "中华网军事战略群";
var message = "这是我发送的第 [" + index + "] 条信息";
index ++;
$("#room-" + room_name).val(message);
setTimeout(function(){
$("#room-" + room_name).trigger("input");
$("button[type=submit]").click();
}, 0);
}
var time = setInterval(sendMessage, 1000)
// ----------直接emit版本---------------------------------------------------------
var index = 1;
function sendMessage() {
var message = "这是我发送的第 [" + index + "] 条信息";
index ++;
socket.emit('chat', JSON.stringify({room: "4MCa4w8FImlU77ePtIdG", msg: message}))
}
var time = setInterval(sendMessage, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment