Merge pull request #184 from thecodingmachine/debugreconnect

Adding console log when trying to reconnect
This commit is contained in:
David Négrier 2020-06-17 15:43:20 +02:00 committed by GitHub
commit b8f9e25b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,10 +22,13 @@ enum EventMessage{
WEBRTC_DISCONNECT = "webrtc-disconect",
GROUP_CREATE_UPDATE = "group-create-update",
GROUP_DELETE = "group-delete",
SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id.
CONNECT_ERROR = "connect_error",
RECONNECT = "reconnect",
SET_PLAYER_DETAILS = "set-player-details" // Send the name and character to the server (on connect), receive back the id.
RECONNECTING = "reconnecting",
RECONNECT_ERROR = "reconnect_error",
RECONNECT_FAILED = "reconnect_failed"
}
class Message {
@ -309,6 +312,18 @@ export class Connection implements ConnectionInterface {
this.GameManager.switchToDisconnectedScene();
});
this.getSocket().on(EventMessage.RECONNECTING, () => {
console.log('Trying to reconnect');
});
this.getSocket().on(EventMessage.RECONNECT_ERROR, () => {
console.log('Error while trying to reconnect.');
});
this.getSocket().on(EventMessage.RECONNECT_FAILED, () => {
console.error('Reconnection failed. Giving up.');
});
this.getSocket().on(EventMessage.RECONNECT, () => {
this.connectSocketServer();
if (this.lastPositionShared === null) {