Skip to content

Instantly share code, notes, and snippets.

@scripting
Created November 6, 2015 17:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scripting/59498807e081b876a2b6 to your computer and use it in GitHub Desktop.
Save scripting/59498807e081b876a2b6 to your computer and use it in GitHub Desktop.
var ws = require ("nodejs-websocket");
var myPort = 1337;
function handleConnection (conn) {
conn.on ("text", function (s) {
var returnstring = s.toUpperCase () + "!!!";
console.log ("handleConnection: returning " + returnstring);
conn.sendText (returnstring)
});
}
ws.createServer (handleConnection).listen (myPort);
@scripting
Copy link
Author

See this blog post for background..

http://scripting.com/2015/11/06/websocketsHelloWorld.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment