mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
first cut at implementing TURN
This commit is contained in:
parent
7ce5cdfc4a
commit
af2098327b
@ -513,6 +513,7 @@ export class Session {
|
|||||||
// TODO: what can we do if this throws?
|
// TODO: what can we do if this throws?
|
||||||
await txn.complete();
|
await txn.complete();
|
||||||
}
|
}
|
||||||
|
await this._updateTurnServers();
|
||||||
// enable session backup, this requests the latest backup version
|
// enable session backup, this requests the latest backup version
|
||||||
if (!this._keyBackup.get()) {
|
if (!this._keyBackup.get()) {
|
||||||
if (dehydratedDevice) {
|
if (dehydratedDevice) {
|
||||||
@ -559,6 +560,18 @@ export class Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _updateTurnServers() {
|
||||||
|
const turnServersData = await this._hsApi.getTurnServers().response();
|
||||||
|
this._callHandler.setTurnServers({
|
||||||
|
urls: turnServerData.uris,
|
||||||
|
username: turnServerData.username,
|
||||||
|
credential: turnServerData.password,
|
||||||
|
});
|
||||||
|
if (turnServersData.ttl > 0) {
|
||||||
|
setTimeout(this._updateTurnServers, turnServersData.ttl * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _getPendingEventsByRoom(txn) {
|
async _getPendingEventsByRoom(txn) {
|
||||||
const pendingEvents = await txn.pendingEvents.getAll();
|
const pendingEvents = await txn.pendingEvents.getAll();
|
||||||
return pendingEvents.reduce((groups, pe) => {
|
return pendingEvents.reduce((groups, pe) => {
|
||||||
|
@ -75,6 +75,12 @@ export class CallHandler implements RoomStateHandler {
|
|||||||
this._loadCallEntries(callEntries, txn);
|
this._loadCallEntries(callEntries, txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setTurnServers(turnServers: RTCIceServer) {
|
||||||
|
this.options.turnServers = turnServers;
|
||||||
|
this.groupCallOptions.turnServers = turnServers;
|
||||||
|
// TODO: we should update any ongoing peerconnections if the TURN server details have changed
|
||||||
|
}
|
||||||
|
|
||||||
private async _getLoadTxn(): Promise<Transaction> {
|
private async _getLoadTxn(): Promise<Transaction> {
|
||||||
const names = this.options.storage.storeNames;
|
const names = this.options.storage.storeNames;
|
||||||
const txn = await this.options.storage.readTxn([
|
const txn = await this.options.storage.readTxn([
|
||||||
|
@ -305,10 +305,14 @@ export class HomeServerApi {
|
|||||||
createRoom(payload: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
createRoom(payload: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||||
return this._post(`/createRoom`, {}, payload, options);
|
return this._post(`/createRoom`, {}, payload, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccountData(ownUserId: string, type: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
setAccountData(ownUserId: string, type: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||||
return this._put(`/user/${encodeURIComponent(ownUserId)}/account_data/${encodeURIComponent(type)}`, {}, content, options);
|
return this._put(`/user/${encodeURIComponent(ownUserId)}/account_data/${encodeURIComponent(type)}`, {}, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTurnServer(options?: BaseRequestOptions): IHomeServerRequest {
|
||||||
|
return this._get(`/voip/turnServer`, undefined, undefined, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import {Request as MockRequest} from "../../mocks/Request.js";
|
import {Request as MockRequest} from "../../mocks/Request.js";
|
||||||
|
Loading…
Reference in New Issue
Block a user