Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Irvin Ocanto
authored and
Irvin Ocanto
committed
May 12, 2013
1 parent
c04d67c
commit 8286e29
Showing
2 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,25 @@ | |||
var connect = require('connect'), | var port = process.env.PORT || 8001; | ||
port = process.env.PORT || 8001; |
|
||
|
|||
var express = require('express') | |||
, app = express() | |||
, server = require('http').createServer(app) | |||
, io = require('socket.io').listen(server); | |||
|
|||
server.listen(port); | |||
|
|||
app.get('/', function (req, res) { | |||
res.sendfile(__dirname + '/index.html'); | |||
}); | |||
|
|||
app.use(express.static(__dirname + '/public')); | |||
|
|||
io.sockets.on('connection', function (socket) { | |||
socket.emit('news', { hello: 'world' }); | |||
socket.on('my other event', function (data) { | |||
console.log(data); | |||
}); | |||
}); | |||
|
|
||
connect.createServer( | |||
connect.static(__dirname + '/public') | |||
).listen( port ); | |||
|
|
||
console.log("Listening on " + port); | console.log("Listening on " + port); |