1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-21 21:09:22 +00:00

Propagate closing of RTC websocket

This commit is contained in:
Pierre HUBERT 2020-04-10 16:19:46 +02:00
parent 36859bbd6d
commit 431463967b
3 changed files with 14 additions and 2 deletions

View File

@ -95,4 +95,10 @@ EventsHelper.Listen("user_ws_closed", async w => {
await CallsController.MakeUserLeaveCall(convID, w.client)
});
// TODO : close all call when RTC WS is closed
// Close all call when RTC WS is closed
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);
}
})

View File

@ -1,6 +1,7 @@
import * as ws from 'ws';
import { Request } from 'express';
import { conf } from '../helpers/ConfigHelper';
import { EventsHelper } from '../helpers/EventsHelper';
/**
* RTC WebSocket relay controller
@ -91,7 +92,8 @@ export class RTCRelayController {
console.info("Closed a connection to RTC relay");
// TODO : do cleanup
// Propagate information
await EventsHelper.Emit("rtc_relay_ws_closed", {});
}
/**

View File

@ -9,6 +9,9 @@ import { ActiveClient } from "../controllers/UserWebSocketController";
* @author Pierre Hubert
*/
// When RTC Relay WebSocket is closed
export interface ClosedRelayWebSocketEvent {}
// When a user sign out
export interface DestroyedLoginTokensEvent {
userID: number,
@ -64,6 +67,7 @@ export interface CommentDeletedEvent {
* Global map of all possible events
*/
export interface EventsMap {
"rtc_relay_ws_closed": ClosedRelayWebSocketEvent,
"destroyed_login_tokens": DestroyedLoginTokensEvent,
"user_ws_closed": UserWebSocketClosedEvent,
"updated_number_notifications": UpdatedNotificationsNumberEvent,