about allowReconnection method, how to get a newer reconnectionToken #834
-
in the code above,i want to save the newer reconnectionToken to my database ,and when i login in the same account in anther web,i want to get back the reconnectionToken to reconnect back.but ,i found client._reconnectionToken is not the newer reconnectionToken,so it will be expired when i use it. how can i get the newer token in this situation.thanks all ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @VicentGogh2025, when the this.allowReconnection(client, 6000).then((newClient) => {
// the reconnection has been reestablished here
console.log("new reconnection token: ", newClient._reconnectionToken);
}).catch(() => {
console.log("reconnection failed:", client.sessionId);
}); On the new version |
Beta Was this translation helpful? Give feedback.
-
https://github.com/orgs/colyseus/discussions/595 |
Beta Was this translation helpful? Give feedback.
Hi @VicentGogh2025, when the
allowReconnection()
resolves, you'll receive the newclient
instance. The newclient
instance has the new reconnection token.On the new version
0.16
, the._reconnectionToken
property has been renamed simply to.reconnectionToken
- also, for convenience, the previous client instance will have its.reconnectionToken
property updated after the reconnection is successful for easy access. (See sources)