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