Somk
Somk

Reputation: 12057

Node.JS Multiple User inteaction

I have just started looking into Node.JS and am very interested in finding out how and if it is possible for multiple users to interact.

For now I am just trying to get a static HTML page to increment a variable say a = 0; Each time a is clicked with a very simple onclick listener.

What I envisage and someone more knowledgeable can tell me if it is possible is. To open that page on two devices. Say my laptop and my phone and be able to click the div incrementing the variable and the number to update on both screens.

Is this something simple? (How "simple" is this?. What would it entail, can it be done without a database and just javascript? Can anyone point me in a direction of research as currently I'm feeling my way around with no direction) I know normally this would be a database driven feature, but I do not need persistence. Literally only while the page is open does the value need to be "remembered".

Upvotes: 0

Views: 45

Answers (1)

E.K
E.K

Reputation: 120

You should try with socket.io.

With the functions socket.emit and socket.on you can trigger event server-side from client-side and vice-versa.

here is the repo with a simple chat example, hope this will help you

Upvotes: 1

Related Questions