I have the following setup using node.js and socket.io
server.js:
var io = require('socket.io').listen(8000);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
index.html:
<html><body><h1>It works!</h1>
<script src="http://ip:8000/socket.io/socket.io.js">
<script>
var socket = io.connect('http://ip:8000');
socket.emit('my other event', { my: 'data' });
</script>
</body></html>
Could anyone please tell me why I don't see any debug messages or I do not receive any communication between them?
You forgot to close your script tag:
<script src="http://ip:8000/socket.io/socket.io.js">
Add </script:
<script src="http://ip:8000/socket.io/socket.io.js"></script>