mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19: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
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export interface RTCSocketMessage {
|
||||||
|
title: string,
|
||||||
|
callId ?: string,
|
||||||
|
peerId ?: string,
|
||||||
|
data: any
|
||||||
|
}
|
||||||
|
|
||||||
export class RTCRelayController {
|
export class RTCRelayController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,8 +65,11 @@ export class RTCRelayController {
|
|||||||
ws.addEventListener("close", () => this.WSClosed());
|
ws.addEventListener("close", () => this.WSClosed());
|
||||||
|
|
||||||
// Send ice configuration to server
|
// Send ice configuration to server
|
||||||
this.SendMessage("config", {
|
this.SendMessage({
|
||||||
iceServers: cnf.iceServers
|
title: "config",
|
||||||
|
data: {
|
||||||
|
iceServers: cnf.iceServers
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,10 +93,12 @@ export class RTCRelayController {
|
|||||||
* @param title The title of the message to send
|
* @param title The title of the message to send
|
||||||
* @param content The content of the message
|
* @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({
|
this.currWs.send(JSON.stringify({
|
||||||
title: title,
|
title: msg.title,
|
||||||
data: content
|
callId: msg.callId,
|
||||||
|
peerId: msg.peerId,
|
||||||
|
data: msg.data
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user