Skip to content

Instantly share code, notes, and snippets.

@hassy
Created October 26, 2013 00:08
Show Gist options
  • Select an option

  • Save hassy/7163730 to your computer and use it in GitHub Desktop.

Select an option

Save hassy/7163730 to your computer and use it in GitHub Desktop.
{
"name": "herokuwstest",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/einaros/ws.git"
},
"dependencies": {
"ws": "0.4.x",
"express": "3.x",
"nodetime": "0.8.x"
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
}
}
web: node server.js
/*
// optional, track OS load, CPU etc with Nodetime
if(process.env.NODETIME_ACCOUNT_KEY) {
require("nodetime").profile({
accountKey: process.env.NODETIME_ACCOUNT_KEY,
appName: "herokuwstest1"
});
}
*/
var WebSocketServer = require('ws').Server
, http = require('http')
, express = require('express')
, app = express()
, port = process.env.PORT || 5000;
app.use(express.static(__dirname + '/'));
var server = http.createServer(app);
server.listen(port);
var wss = new WebSocketServer({server: server});
wss.on('connection', function(ws) {
ws.send(JSON.stringify(new Date()), function() {});
ws.on('close', function() {
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment