From aae5326bf977e9138fde0d8ca15cf6a2bc80d326 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 25 Jan 2019 14:50:23 +0100 Subject: [PATCH] Added a method to check if the socket is connected to the server or not --- client/SignalExchangerClient.js | 9 +++++++++ video-client/SignalExchangerClient.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/client/SignalExchangerClient.js b/client/SignalExchangerClient.js index 62649e5..7eef03b 100644 --- a/client/SignalExchangerClient.js +++ b/client/SignalExchangerClient.js @@ -119,6 +119,15 @@ class SignalExchangerClient { }); } + /** + * Use this method to get the current connection status to the server + * + * @return {Boolean} TRUE if the client is connected to the server / FALSE else + */ + isConnected() { + return this.socket.readyState == WebSocket.OPEN; + } + /** * Method called once the client is successfully * connected to the client diff --git a/video-client/SignalExchangerClient.js b/video-client/SignalExchangerClient.js index 62649e5..7eef03b 100644 --- a/video-client/SignalExchangerClient.js +++ b/video-client/SignalExchangerClient.js @@ -119,6 +119,15 @@ class SignalExchangerClient { }); } + /** + * Use this method to get the current connection status to the server + * + * @return {Boolean} TRUE if the client is connected to the server / FALSE else + */ + isConnected() { + return this.socket.readyState == WebSocket.OPEN; + } + /** * Method called once the client is successfully * connected to the client