mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Send ICE configuration to server
This commit is contained in:
parent
e8a0e70ffe
commit
6aec00b3f4
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
"rtc_relay": {
|
"rtc_relay": {
|
||||||
"ip": "::ffff:127.0.0.1",
|
"ip": "::ffff:127.0.0.1",
|
||||||
"token": "SecretToken"
|
"token": "SecretToken",
|
||||||
|
"iceServers": [
|
||||||
|
"stun:stun.l.google.com:19302"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,6 +55,38 @@ export class RTCRelayController {
|
|||||||
this.currWs = ws;
|
this.currWs = ws;
|
||||||
|
|
||||||
// Register to events
|
// Register to events
|
||||||
|
ws.addEventListener("close", () => this.WSClosed());
|
||||||
|
|
||||||
|
// Send ice configuration to server
|
||||||
|
this.SendMessage("config", {
|
||||||
|
iceServers: cnf.iceServers
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when a websocket connection is closed
|
||||||
|
*/
|
||||||
|
private static async WSClosed() {
|
||||||
|
|
||||||
|
// Check if this is caused to a new connection
|
||||||
|
if (this.currWs.readyState != ws.OPEN)
|
||||||
|
this.currWs = null;
|
||||||
|
|
||||||
|
console.info("Closed a connection to RTC relay");
|
||||||
|
|
||||||
|
// TODO : do cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a new message to the server
|
||||||
|
*
|
||||||
|
* @param title The title of the message to send
|
||||||
|
* @param content The content of the message
|
||||||
|
*/
|
||||||
|
private static async SendMessage(title: string, content: any) {
|
||||||
|
this.currWs.send(JSON.stringify({
|
||||||
|
title: title,
|
||||||
|
data: content
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ export interface DatabaseConfiguration {
|
|||||||
export interface RTCRelayConfiguration {
|
export interface RTCRelayConfiguration {
|
||||||
ip ?: string,
|
ip ?: string,
|
||||||
token: string,
|
token: string,
|
||||||
|
iceServers: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Configuration {
|
export interface Configuration {
|
||||||
|
Loading…
Reference in New Issue
Block a user