1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-25 06:49:23 +00:00

Upgrade call information

This commit is contained in:
Pierre HUBERT 2020-04-11 14:25:06 +02:00
parent 29736cd98d
commit 3cae1220c3
2 changed files with 15 additions and 6 deletions

View File

@ -53,7 +53,9 @@ export class CallsController {
await this.MakeUserLeaveCall(convID, c) await this.MakeUserLeaveCall(convID, c)
h.wsClient.activeCalls.add(convID); h.wsClient.activeCalls.set(convID, {
ready: false
});
// Notify all other users // Notify all other users
await UserWebSocketController.SendToSpecifcClients( await UserWebSocketController.SendToSpecifcClients(
@ -102,7 +104,10 @@ export class CallsController {
h.send(UserWebSocketController.active_clients.filter( h.send(UserWebSocketController.active_clients.filter(
(f) => f.activeCalls.has(convID) (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 // Listen for websocket closed
EventsHelper.Listen("user_ws_closed", async w => { EventsHelper.Listen("user_ws_closed", async w => {
for(const convID of w.client.activeCalls) 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 // Listen to signal from RTC proxy
@ -203,6 +208,6 @@ EventsHelper.Listen("rtc_relay_signal", async msg => {
EventsHelper.Listen("rtc_relay_ws_closed", async () => { EventsHelper.Listen("rtc_relay_ws_closed", async () => {
for(const client of UserWebSocketController.active_clients) { for(const client of UserWebSocketController.active_clients) {
for(const convID of client.activeCalls) for(const convID of client.activeCalls)
await CallsController.MakeUserLeaveCall(convID, client); await CallsController.MakeUserLeaveCall(convID[0], client);
} }
}) })

View File

@ -21,6 +21,10 @@ interface PendingRequests {
incognito: boolean incognito: boolean
} }
export interface CallStatus {
ready: boolean
}
export interface ActiveClient { export interface ActiveClient {
socketID: string, socketID: string,
clientID: number, clientID: number,
@ -30,7 +34,7 @@ export interface ActiveClient {
registeredConversations: Set<number>, registeredConversations: Set<number>,
registeredPosts: Set<number>, registeredPosts: Set<number>,
activeCalls: Set<number>, activeCalls: Map<number, CallStatus>, // number = conversations id
} }
// Tokens are valid only 10 seconds after they are generated // Tokens are valid only 10 seconds after they are generated
@ -123,7 +127,7 @@ export class UserWebSocketController {
incognito: entry.incognito, incognito: entry.incognito,
registeredConversations: new Set(), registeredConversations: new Set(),
registeredPosts: new Set(), registeredPosts: new Set(),
activeCalls: new Set(), activeCalls: new Map(),
} }
this.active_clients.push(client); this.active_clients.push(client);