Skip to content

Instantly share code, notes, and snippets.

@JangoSteve
Created May 17, 2013 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JangoSteve/5600689 to your computer and use it in GitHub Desktop.
Save JangoSteve/5600689 to your computer and use it in GitHub Desktop.
Websocket Presentation Abstract
// Steve (server)
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8080});
wss.on('connection', function(ws) {
ws.on('message', function(message) {
ws.send("Sure thing, how's this?");
});
});
// Brian (browser)
var connection = new WebSocket('ws://steve.alfajango.com', ['soap', 'xmpp']);
connection.onopen = function () {
connection.send("Can we please get an abstract for this presentation?");
};
connection.onmessage = function(message) {
if (message) {
connection.send("Awesome, thanks!");
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment