M
M
mamaenko2016-11-24 20:26:33
Node.js
mamaenko, 2016-11-24 20:26:33

How to implement connection resumption in socket.io?

In online games such as agar.io, when the internet connection is cut off and then resumed within a short period of time, the client continues from the same place where he left off. On the server, I am using socket.io.
io.on("connection",function (socket) {
console.log("Player "+socket.id+" connected");
});
The problem is that when reconnecting, the server creates another connection with a new socket and id. The question is how to find out that the same client is connected that disconnected a couple of seconds ago? I thought to store on the client the id of the first connection, which is transferred to the server. Is this the normal approach? Maybe you can resume the session automatically?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ro37A, 2016-11-24
@mamaenko

Maybe this Stack Overflow solution will help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question