From 3cae1220c3af84954ea8b9eff49dd01dc6bdf4b2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 11 Apr 2020 14:25:06 +0200 Subject: [PATCH] Upgrade call information --- src/controllers/CallsController.ts | 13 +++++++++---- src/controllers/UserWebSocketController.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index 586dc85..87f0ac8 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -53,7 +53,9 @@ export class CallsController { await this.MakeUserLeaveCall(convID, c) - h.wsClient.activeCalls.add(convID); + h.wsClient.activeCalls.set(convID, { + ready: false + }); // Notify all other users await UserWebSocketController.SendToSpecifcClients( @@ -102,7 +104,10 @@ export class CallsController { h.send(UserWebSocketController.active_clients.filter( (f) => f.activeCalls.has(convID) - ).map(f => f.userID)) + ).map(f => {return { + userID: f.userID, + ready: f.activeCalls.get(convID).ready + }})) } /** @@ -191,7 +196,7 @@ export class CallsController { // Listen for websocket closed EventsHelper.Listen("user_ws_closed", async w => { for(const convID of w.client.activeCalls) - await CallsController.MakeUserLeaveCall(convID, w.client) + await CallsController.MakeUserLeaveCall(convID[0], w.client) }); // Listen to signal from RTC proxy @@ -203,6 +208,6 @@ EventsHelper.Listen("rtc_relay_signal", async msg => { EventsHelper.Listen("rtc_relay_ws_closed", async () => { for(const client of UserWebSocketController.active_clients) { for(const convID of client.activeCalls) - await CallsController.MakeUserLeaveCall(convID, client); + await CallsController.MakeUserLeaveCall(convID[0], client); } }) diff --git a/src/controllers/UserWebSocketController.ts b/src/controllers/UserWebSocketController.ts index 94f3139..94afdae 100644 --- a/src/controllers/UserWebSocketController.ts +++ b/src/controllers/UserWebSocketController.ts @@ -21,6 +21,10 @@ interface PendingRequests { incognito: boolean } +export interface CallStatus { + ready: boolean +} + export interface ActiveClient { socketID: string, clientID: number, @@ -30,7 +34,7 @@ export interface ActiveClient { registeredConversations: Set, registeredPosts: Set, - activeCalls: Set, + activeCalls: Map, // number = conversations id } // Tokens are valid only 10 seconds after they are generated @@ -123,7 +127,7 @@ export class UserWebSocketController { incognito: entry.incognito, registeredConversations: new Set(), registeredPosts: new Set(), - activeCalls: new Set(), + activeCalls: new Map(), } this.active_clients.push(client);