I have a working server that's using sockets. My server-side code looks like this:
io.sockets.on('connection', function(socket) {
socket.emit('status', { counter: count });
});
In this example, I'm simply incrementing a counter by 1 every minute. When the counter updates, I'd like to send the current count to all clients. My index.html
file looks like this:
<script>
var socket = io.connect('http://localhost');
socket.on('status', function (data) {
console.log(data);
});
</script>
When I start up my server, I can see the first data send to the client {'counter': 0}
, however when the value of the counter increments, I don't see the new value being updated on the client. Why isn't new data being sent to my clients?