public
Created

  • Download Gist
websocket-extension.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
* A simple ringo websocket extension. Add the following code to your webapp's
* config.js file to enable it:
*
* exports.extensions = ["websocket-extension"];
*/
 
var websocket = require("ringo/webapp/websocket");
 
exports.serverStarted = function(server) {
var context = server.getDefaultContext();
websocket.addWebSocket(context, "/websocket", function (socket) {
// export socket to let us play with it
exports.socket = socket;
 
socket.onmessage = function(m) {
print("MESSAGE", m);
};
 
socket.onclose = function() {
print("CLOSE");
};
});
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.