From d1235f4f8c657d0e4bcce3f9b4238bc761412bee Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Apr 2020 10:23:32 +0200 Subject: [PATCH] Improve messages format --- src/controllers/RTCRelayController.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/controllers/RTCRelayController.ts b/src/controllers/RTCRelayController.ts index 278b9bc..c36ede3 100644 --- a/src/controllers/RTCRelayController.ts +++ b/src/controllers/RTCRelayController.ts @@ -8,6 +8,13 @@ import { conf } from '../helpers/ConfigHelper'; * @author Pierre HUBERT */ +export interface RTCSocketMessage { + title: string, + callId ?: string, + peerId ?: string, + data: any +} + export class RTCRelayController { /** @@ -58,8 +65,11 @@ export class RTCRelayController { ws.addEventListener("close", () => this.WSClosed()); // Send ice configuration to server - this.SendMessage("config", { - iceServers: cnf.iceServers + this.SendMessage({ + title: "config", + data: { + iceServers: cnf.iceServers + }, }) } @@ -83,10 +93,12 @@ export class RTCRelayController { * @param title The title of the message to send * @param content The content of the message */ - private static async SendMessage(title: string, content: any) { + private static async SendMessage(msg: RTCSocketMessage) { this.currWs.send(JSON.stringify({ - title: title, - data: content + title: msg.title, + callId: msg.callId, + peerId: msg.peerId, + data: msg.data })); } } \ No newline at end of file