From b14524625c47fabe0a29094a0e1ce7edd2e8eed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 17 Jun 2020 15:37:02 +0200 Subject: [PATCH] Adding console log when trying to reconnect --- front/src/Connection.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 15e58707..996f3914 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -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 { @@ -308,6 +311,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) {