From 38858e956de6e8f6c695d1d128828be38ef0a2b8 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 11 Apr 2020 14:39:17 +0200 Subject: [PATCH] Can mark a user as ready --- src/controllers/CallsController.ts | 22 ++++++++++++++++++++++ src/controllers/UserWebSocketRoutes.ts | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index 87f0ac8..05fcf6b 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -170,6 +170,28 @@ export class CallsController { } + /** + * Mark a user as ready to share its streams + * + * @param h Request handler + */ + public static async MarkUserReady(h: UserWebSocketRequestsHandler) { + const callID = h.postCallId("callID"); + + h.wsClient.activeCalls.get(callID).ready = true; + + // Notify all other users + await UserWebSocketController.SendToSpecifcClients( + (c) => c.activeCalls.has(callID) && c.userID != h.getUserId(), + () => WsMessage.NoIDMessage("user_ready", { + callID: callID, + userID: h.getUserId() + }) + ) + + h.success(); + } + /** * Make the client leave the call * diff --git a/src/controllers/UserWebSocketRoutes.ts b/src/controllers/UserWebSocketRoutes.ts index 3506918..dea449e 100644 --- a/src/controllers/UserWebSocketRoutes.ts +++ b/src/controllers/UserWebSocketRoutes.ts @@ -42,4 +42,6 @@ export const UserWebSocketRoutes: UserWebSocketRoute[] = [ {title: "calls/members", handler: (h) => CallsController.GetMembersList(h)}, {title: "calls/signal", handler: (h) => CallsController.OnClientSignal(h)}, + + {title: "calls/mark_ready", handler: (h) => CallsController.MarkUserReady(h)}, ] \ No newline at end of file