mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Propagate closing of RTC websocket
This commit is contained in:
		@@ -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);
 | 
			
		||||
	}
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -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", {});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user