-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (35 loc) · 1.25 KB
/
app.js
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
39
40
import AppClient from "./app/appClient.js";
import AppServer from "./app/appServer.js";
import AppMobile from "./app/appMobile.js";
export default class Application {
/**
* @param {Element} root
*/
constructor(root) {
this.root = root
}
start() {
const serverPeerIdParam = "connectPeer";
const sideParam = "side";
const currentUrl = new URL(window.location.href)
const serverPeerId = currentUrl.searchParams.get(serverPeerIdParam)
if (!serverPeerId) {
const server = new AppServer(this.root, (peerId, side) => {
const inviteLinkUrl = new URL(window.location.href)
inviteLinkUrl.searchParams.set(serverPeerIdParam, peerId)
if (side) {
inviteLinkUrl.searchParams.set(sideParam, side)
}
return inviteLinkUrl.toString()
})
return server.showMenu()
}
const side = currentUrl.searchParams.get(sideParam)
if (side) {
const client = new AppMobile(this.root, serverPeerId, side)
return client.showLoading()
}
const client = new AppClient(this.root, serverPeerId)
return client.showLoading()
}
}