diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index 1958822..9636904 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -237,6 +237,31 @@ export class CallsController { h.success() } + /** + * Notify the user stopped to stream + * + * @param h Request handler + */ + public static async UserInterruptedStreaming(h: UserWebSocketRequestsHandler) { + const callID = h.postCallId("callID"); + + // Propagate notification only if required + if(h.wsClient.activeCalls.get(callID).ready) { + h.wsClient.activeCalls.get(callID).ready = false; + + // Notify all other users + await UserWebSocketController.SendToSpecifcClients( + (c) => c.activeCalls.has(callID) && c.userID != h.getUserId(), + () => WsMessage.NoIDMessage("call_peer_interrupted_streaming", { + callID: callID, + peerID: h.getUserId() + }) + ) + } + + h.success(); + } + /** * Make the client leave the call * diff --git a/src/controllers/UserWebSocketRoutes.ts b/src/controllers/UserWebSocketRoutes.ts index af9ff8e..621372f 100644 --- a/src/controllers/UserWebSocketRoutes.ts +++ b/src/controllers/UserWebSocketRoutes.ts @@ -46,4 +46,6 @@ export const UserWebSocketRoutes: UserWebSocketRoute[] = [ {title: "calls/mark_ready", handler: (h) => CallsController.MarkUserReady(h)}, {title: "calls/request_offer", handler: (h) => CallsController.RequestOffer(h)}, + + {title: "calls/stop_streaming", handler: (h) => CallsController.UserInterruptedStreaming(h)}, ] \ No newline at end of file