From 1d224dd201f92d951a1ae0e148c17b7e8e95fe29 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 11 Apr 2020 18:21:06 +0200 Subject: [PATCH] Can request offers from server --- src/controllers/CallsController.ts | 23 +++++++++++++++++++++++ src/controllers/UserWebSocketRoutes.ts | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index 372f993..b98054f 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -202,6 +202,29 @@ export class CallsController { h.success(); } + /** + * Request an offer from the server + * + * @param h Request handler + */ + public static async RequestOffer(h: UserWebSocketRequestsHandler) { + const callID = h.postCallId("callID"); + const peerID = h.postCallPeerID(callID, "peerID"); // The ID of the user we stream the audio / video from + + if(peerID == 0 || peerID == h.getUserId()) + h.error(401, "You can not request an offer for yourself!"); + + // Proxify the request to the server + await RTCRelayController.SendMessage({ + title: "request_offer", + callHash: this.genCallHash(callID, peerID), + peerId: String(h.getUserId()), + data: "" + }) + + h.success() + } + /** * Make the client leave the call * diff --git a/src/controllers/UserWebSocketRoutes.ts b/src/controllers/UserWebSocketRoutes.ts index dea449e..af9ff8e 100644 --- a/src/controllers/UserWebSocketRoutes.ts +++ b/src/controllers/UserWebSocketRoutes.ts @@ -44,4 +44,6 @@ export const UserWebSocketRoutes: UserWebSocketRoute[] = [ {title: "calls/signal", handler: (h) => CallsController.OnClientSignal(h)}, {title: "calls/mark_ready", handler: (h) => CallsController.MarkUserReady(h)}, + + {title: "calls/request_offer", handler: (h) => CallsController.RequestOffer(h)}, ] \ No newline at end of file