-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
38 lines (34 loc) · 1.21 KB
/
test.html
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
<!doctype html>
<html>
<head>
<title>test</title>
</head>
<body>
<div>
<div> <input placeholder="URL" id="base-url"/> </div>
<button id="start" class="button-4">Start</button>
</div>
<script type="module">
import networkService from './networkService.js'
document.getElementById("start").addEventListener("click", () => {
connect()
})
async function connect(){
const urlObj = new URL(document.getElementById("base-url").value)
const searchParams = urlObj.searchParams
const useSmoke = true
let ws = null
const infoHash = searchParams.has("infoHash")? searchParams.get("infoHash") : ""
const wsUrl = 'wss://tracker.files.fm:7073'
ws = new WebSocket(wsUrl)
const peerId = window.crypto.randomUUID().replaceAll('-', '').slice(0, 20)
networkService.setNetwork(ws, infoHash, peerId, urlObj.origin)
ws.addEventListener('open', async () => {
console.log("ws open")
const text = await networkService.smokeClient.Http.fetch([networkService.remoteAddr, "v1/models"].join("/")).then(r => r.text());
console.log(text);
})
}
</script>
</body>
</html>