From 9a44e9370cb3398bb4bb08a4a85f1d303a90031f Mon Sep 17 00:00:00 2001 From: MetaMuffin Date: Fri, 6 Aug 2021 08:58:38 +0200 Subject: a --- source/client/local_user.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 source/client/local_user.ts (limited to 'source/client/local_user.ts') diff --git a/source/client/local_user.ts b/source/client/local_user.ts new file mode 100644 index 0000000..10a87b7 --- /dev/null +++ b/source/client/local_user.ts @@ -0,0 +1,34 @@ +import { RemoteUser } from "./remote_user"; +import { Room } from "./room"; +import { User } from "./user"; + + +export class LocalUser extends User { + constructor(room: Room, name: string) { + super(room, name) + this.get_streams() + } + + async get_streams() { + const user_media = await window.navigator.mediaDevices.getUserMedia({ audio: true, video: true }) + await new Promise(r => setTimeout(() => r(), 3000)) + for (const t of user_media.getTracks()) { + this.add_track(t) + } + } + + add_tracks_to_remote(u: RemoteUser) { + this.stream.forEach(t => { + u.peer.addTrack(t, new MediaStream()) + }) + } + + add_track(t: MediaStreamTrack) { + this.update_view() + this.stream.push(t) + this.room.remote_users.forEach(u => { + u.peer.addTrack(t) + }) + } + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2