Sha256: 2ffdf67f7e23471a75da0f8af3df6641dd12a1eb79e0053d07c948b699b6e4b5
Contents?: true
Size: 828 Bytes
Versions: 35
Compression:
Stored size: 828 Bytes
Contents
var io = new WebSocketIO().connect(); io.on("chat", function(data){ var m = $("<li>").text(data.name + " : " +data.message); $("#chat #timeline").prepend(m); }); io.on("connect", function(session){ console.log("connect!! "+session); $("#chat #btn_send").click(post); $("#chat #message").keydown(function(e){ if(e.keyCode == 13) post(); }); }); io.on("disconnect", function(session){ console.log("disconnect!!"); }); io.on("*", function(event, data){ // catch all events console.log(event + " - " + JSON.stringify(data)); }); io.on("error", function(err){ console.error(err); }); var post = function(){ var name = $("#chat #name").val(); var message = $("#chat #message").val(); if(message.length < 1) return; io.push("chat", {name: name, message: message}); $("#chat #message").val(""); };
Version data entries
35 entries across 35 versions & 1 rubygems