From de8e2d40ed2744c4c25ec7cdbe778e1723dbb830 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 9 Sep 2022 15:35:56 +0200 Subject: refactor + identify --- client-web/source/user/local.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'client-web/source/user/local.ts') diff --git a/client-web/source/user/local.ts b/client-web/source/user/local.ts index a741726..2ea1ea6 100644 --- a/client-web/source/user/local.ts +++ b/client-web/source/user/local.ts @@ -7,7 +7,7 @@ import { get_rnnoise_node } from "../rnnoise.ts"; import { Room } from "../room.ts"; import { TrackHandle } from "../track_handle.ts"; import { User } from "./mod.ts"; -import { BOTTOM_CONTAINER } from "../index.ts"; +import { BOTTOM_CONTAINER, ROOM_CONTAINER } from "../index.ts"; export class LocalUser extends User { mic_gain?: GainNode @@ -17,10 +17,16 @@ export class LocalUser extends User { super(room, id) this.el.classList.add("local") this.local = true + this.name = PREFS.username this.create_controls() this.add_initial_tracks() log("usermodel", `added local user: ${this.display_name}`) } + leave() { // we might never need this but ok + this.room.local_user = undefined as unknown as LocalUser + super.leave() + ROOM_CONTAINER.removeChild(this.el) + } async add_initial_tracks() { if (PREFS.microphone_enabled) this.publish_track(await this.create_mic_track()) @@ -43,6 +49,9 @@ export class LocalUser extends User { add_initial_to_remote(u: RemoteUser) { this.tracks.forEach(t => u.peer.addTrack(t.track)) } + identify(recipient?: number) { + if (this.name) this.room.signaling.send_relay({ identify: { username: this.name } }, recipient) + } create_controls() { const mic_toggle = document.createElement("input") -- cgit v1.2.3-70-g09d2