]> Repos - mime-chat/commitdiff
add socket close connection code and reason
authorEnrique H. Oliva <hernandeze2@xavier.edu>
Tue, 13 Jul 2021 13:32:05 +0000 (08:32 -0500)
committerEnrique H. Oliva <hernandeze2@xavier.edu>
Tue, 13 Jul 2021 13:32:05 +0000 (08:32 -0500)
src/composables/useWebsockets.ts
src/session.ts
yarn.lock

index 13d47c355effdf8712b9be3d2ded9c8a7222a688..3b9f2c999aab109ce4d8d11ffe6c3cd74ef7dbc4 100644 (file)
@@ -69,10 +69,10 @@ export default function useWebSockets(
             messageCallback(event.toString())
         });
 
-        socket.on("close", (event: WebSocket.CloseEvent) => {
+        socket.on("close", (code: number, reason: string) => {
             connectionStatusCallback(statusOptions ? statusOptions.closeMessage : "Connection Closed");
             clearInterval(_connectionCheckInterval);
-            if (!event.wasClean) {
+            if (code !== 1000 || reason !== 'session-logout') {
                 setTimeout(() => {
                     connect(socketUrl, secret), _reconnectTimeout
                 });
@@ -86,9 +86,9 @@ export default function useWebSockets(
 
     }
 
-    const close = () => {
+    const close = (code: number, reason: string) => {
         if (socket) {
-            socket.close();
+            socket.close(code, reason);
         }
     };
 
index cbf2b103234ed586bbf94f5cbb8b1c196cb2c845..9446cd0b896759e82f967db7e9b654b62ca28e56 100644 (file)
@@ -57,14 +57,14 @@ export function launchSession(platformKey: string) {
     /* connect to the platform */
     connect(config.PLATFORM_URL, platformKey);
 
-    //  initialize the audio streams 
+    //  initialize the audio streams
     // audio.record();
 
 }
 
 export function endSession() {
 
-    close();
+    close(1000, 'session-logout');
 
     uiState.reset();
 
index 465adc92b1561f2f99ed954c208ccf343d9ac1b0..e79f19f4206b26a835d230a4d20b7b4993018baf 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -4898,11 +4898,6 @@ dotenv-expand@^5.1.0:
   resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
   integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
 
-dotenv@^10.0.0:
-  version "10.0.0"
-  resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
-  integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
-
 dotenv@^8.2.0:
   version "8.2.0"
   resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"