Monday, 5 August 2019

Sending one simple variable from node.js web server to client via socket.io

Hello fellow redditors , I've just started playing with Node.js and I'm amazed of its strenght as a jack-of-all trades of programming. As a noobie , I spent a lot of time lurking on the web getting knowledge , but It seems I can't find documentation about sending one simple variable to client.What I tried is a simple setInterval with a io.emit(Var)if (level==1){ if(count<2){ count=count+1; console.log(count); socket.emit(count); } if(count==2){ socket.emit(count); setTimeout(Enviar_Reset,5000); } And the same in the client.setInterval(function(){ Estado=socket.on('count'); if(Estado==0){ Crono(); } },1); I found a lot of information about sending objects, but Is it possible to send just one variable in a simple way?(Security is not a concern as it's a local environment)

Submitted August 05, 2019 at 08:41AM by Shadow_Galecross

No comments:

Post a Comment