Hello
I'm working with nodejs, what I have now is that it adds 1 second = +1.
What I want is if you jiont with a new browser that game will count where
the other remained. So the other at 10 then the other also start at 10 and
not at 0
My code:
app.js
io.sockets.on('connection', function (socket) {
var counter = 0;
socket.on('testconnection', function() {
setInterval(function() {
var time = counter++;
console.log(time);
socket.emit('time', time);
}, 1000 );
});
});
HTML
var socket = io.connect('http://localhost:8080');
socket.emit('testconnection');
socket.on('time', function(data){
document.getElementById("demo").innerHTML= data;
});
I hope if you can help me, I've tried console.log but I do not know how I
can give console.log back. (socket.emit('time', (here consolelog);)
Sorry for bad english me, I'm a Dutchman who can english bad.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.