mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-21 21:09:22 +00:00
Improve messages format
This commit is contained in:
parent
6aec00b3f4
commit
d1235f4f8c
@ -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
|
||||
}));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user