R
R
Raydon122021-06-18 12:46:35
Node.js
Raydon12, 2021-06-18 12:46:35

How to use socket.io to connect to an already existing connection?

Hey! Is it possible on the client to connect to an already existing socket.io connection? On my client, the connect and emit functions are moved to a separate Sock class. When logging into the application, the client connects to this class from the application's login class, calls connect, and sends and assigns the desired id to the socket using socket.connect, socket.emit("signin", id). But if I try to call socket.emit from another class, such as a class with messages, then I get an error saying that you are trying to send a message to a non-existent connection. Before that, I called the class with my two Sock functions socket = new Sock( ); I hope I didn't confuse too much. If so, please specify in the comments)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question