Skip to content

Instantly share code, notes, and snippets.

@hns
Created August 28, 2010 21:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hns/555596 to your computer and use it in GitHub Desktop.
Save hns/555596 to your computer and use it in GitHub Desktop.
/*
* 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");
};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment