forked from anyproto/go-threads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
37 lines (36 loc) · 1.14 KB
/
index.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
<!--
This is an example of a web client opening a ws connection to Threads.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
window.addEventListener('load', function() {
const socket = new WebSocket('ws:https://localhost:8080')
socket.addEventListener('open', function (e) {
console.log('Connection started.')
// Subscribe to thread in URL query
let threads
let params = new URLSearchParams(window.location.search);
if (params.has('thread')) {
threads = params.getAll('thread')
}
let msg = {
type: 'subscribe',
threads: threads
}
socket.send(JSON.stringify(msg))
})
socket.addEventListener('message', function (e) {
console.log('Record: ', e.data)
})
socket.addEventListener('error', function (e) {
console.error("Error: ", e)
})
});
</script>
<title>Threads</title>
</head>
<body></body>
</html>