mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-10-31 09:34:44 +00:00 
			
		
		
		
	Improve messages format
This commit is contained in:
		| @@ -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", { | ||||
| 		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 | ||||
| 		})); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user