Skip to content

Commit

Permalink
socketio example works!
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Oct 11, 2011
1 parent 18c1a90 commit c26c66c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example/socketio/bounce.js
@@ -0,0 +1,4 @@
var bouncy = require('bouncy');
bouncy(function (req, bounce) {
bounce(5001);
}).listen(8081);
14 changes: 14 additions & 0 deletions example/socketio/index.html
@@ -0,0 +1,14 @@
<html>
<head>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
var socket = io.connect();
socket.on('news', function (data) {
document.body.innerHTML += data.news;
socket.emit('blues', "I've got the bouncy websocket spec blues.");
});
</script>
</head>
<body>
</body>
</html>
5 changes: 5 additions & 0 deletions example/socketio/package.json
@@ -0,0 +1,5 @@
{
"dependencies" : {
"socket.io" : "0.8.5"
}
}
14 changes: 14 additions & 0 deletions example/socketio/server.js
@@ -0,0 +1,14 @@
var connect = require('connect');
var app = connect.createServer();
app.use(connect.static(__dirname))

var io = require('socket.io')

var s = io.listen(app);
s.sockets.on('connection', function (socket) {
socket.emit('news', { news : 'THERE IS NO NEWS TO REPORT.' });
socket.on('blues', function (blues) {
console.log('I gots the blues: ' + blues);
});
});
app.listen(5001);

0 comments on commit c26c66c

Please sign in to comment.