Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functions for connecting to endpoints
Example updated
- Loading branch information
Showing
5 changed files
with
56 additions
and
4 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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var io = require('socket.io').listen(8080); | ||
|
||
var chat = io | ||
.of('/chat') | ||
.on('connection', function (socket) { | ||
socket.emit('a message', { | ||
that: 'only' | ||
, '/chat': 'will get' | ||
}); | ||
chat.emit('a message', { | ||
everyone: 'in' | ||
, '/chat': 'will get' | ||
}); | ||
}); | ||
|
||
var news = io | ||
.of('/news') | ||
.on('connection', function (socket) { | ||
socket.emit('item', { news: 'item' }); | ||
}); | ||
|
||
io.sockets.on('connection', function (socket) { | ||
socket.on('test', function (msg) { | ||
console.log('Test message: ', msg); | ||
}); | ||
}); |
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