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