-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.tsx
38 lines (35 loc) · 1.21 KB
/
entrypoint.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const ownMediaStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }).catch(console.error);
const ownVideo = <video autoplay src={ownMediaStream} /> as HTMLVideoElement
const remoteVideo = <video autoplay/> as HTMLVideoElement
const remoteEndpoint = eternal ?? $(""); // store the remote endpoint persistently
@endpoint class CallManager {
/**
* This function is called remotely from one endpoint to initiate a video call
* @param mediaStream the media stream of the caller endpoint
* @returns the media stream of the called endpoint
*/
@property static call(mediaStream: MediaStream|null) {
remoteEndpoint.val = datex.meta.caller.main.toString()
remoteVideo.srcObject = mediaStream;
return ownMediaStream!;
}
}
export default
<main>
<h1>Video Call</h1>
<div class="callView">
<div>
{ownVideo}
<div>Your Endpoint: <b>{localEndpoint.main.toString()}</b></div>
</div>
<div>
{remoteVideo}
<div>
Remote Endpoint: <input value={remoteEndpoint}/>
<button onclick={async () => {
remoteVideo.srcObject = await CallManager.call.to(remoteEndpoint.val)(ownMediaStream!);
}}><i class="fa-solid fa-video"/> Call</button>
</div>
</div>
</div>
</main>