Sanae6 / SmoOnlineServer

Official server for Super Mario Odyssey: Online
https://discord.gg/jYCueK2BqD
108 stars 27 forks source link

fix: on reconnect do not disconnect the new client #35

Closed Istador closed 1 year ago

Istador commented 2 years ago

Currently when a client connects that is already there, the old socket is closed, and the code tries to reuse the existing client object by exchanging its socket.

Reusing the same client object and just changing its socket does cause issues though with copies of the client in other threads. In the situations that I could reproduce, it always disconnected both sockets, the old one and then the new one.

Instead I make a copy of the client object, use the new socket, remove the old object and add the new object to the collection.

(cherry picked from commit 9e6c312c8e2f4967cf08a6d7c46f6c7779f847f3)