New to node.js and struggling with socket.io

Hi all,

Nervous first post but really need some help. I’m working on a Web application for p2p communication (both video and text).

The video communication works (some teething issues), but my main issue is getting user socket.id. specifically the u…


This content originally appeared on DEV Community and was authored by Fletcher Moore

Hi all,

Nervous first post but really need some help. I'm working on a Web application for p2p communication (both video and text).

The video communication works (some teething issues), but my main issue is getting user socket.id. specifically the user just having connected.

I have tried many things including:
Socket.on("connected", () {
console.log(socket.id);
});

All I get is "undefined". Yet if I run te same console.log code after the page loads I can get it displayed.

Not sure how to work with that.

I want to store the socket.id and username in an object/array

Thank you


This content originally appeared on DEV Community and was authored by Fletcher Moore


Print Share Comment Cite Upload Translate Updates
APA

Fletcher Moore | Sciencx (2021-07-09T14:02:10+00:00) New to node.js and struggling with socket.io. Retrieved from https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/

MLA
" » New to node.js and struggling with socket.io." Fletcher Moore | Sciencx - Friday July 9, 2021, https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/
HARVARD
Fletcher Moore | Sciencx Friday July 9, 2021 » New to node.js and struggling with socket.io., viewed ,<https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/>
VANCOUVER
Fletcher Moore | Sciencx - » New to node.js and struggling with socket.io. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/
CHICAGO
" » New to node.js and struggling with socket.io." Fletcher Moore | Sciencx - Accessed . https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/
IEEE
" » New to node.js and struggling with socket.io." Fletcher Moore | Sciencx [Online]. Available: https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/. [Accessed: ]
rf:citation
» New to node.js and struggling with socket.io | Fletcher Moore | Sciencx | https://www.scien.cx/2021/07/09/new-to-node-js-and-struggling-with-socket-io/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.