Created
October 26, 2013 00:08
-
-
Save hassy/7163730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| web: node server.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| // 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