tangled
alpha
login
or
join now
accidental.cc
/
skypod
3
fork
atom
podcast manager
3
fork
atom
overview
issues
pulls
pipelines
make it clear it's a method not a getter
Jonathan Raphaelson
8 months ago
0d951df4
d661e6fc
+3
-7
2 changed files
expand all
collapse all
unified
split
src
client
components
peer-list.tsx
realm
connection.ts
+1
-3
src/client/components/peer-list.tsx
···
10
10
11
11
useEffect(() => {
12
12
const updatePeers = () => {
13
13
-
queueMicrotask(() => {
14
14
-
setPeers(webrtcManager.peers)
15
15
-
})
13
13
+
setPeers(webrtcManager.peerStates())
16
14
}
17
15
18
16
// Listen to WebRTC events
+2
-4
src/client/realm/connection.ts
···
51
51
this.#nonces = new Map()
52
52
53
53
console.debug('realm connection starting!')
54
54
+
54
55
this.#socket = new WebSocket(this.#url)
55
56
this.#socket.onopen = this.#handleSocketOpen
56
57
this.#socket.onclose = this.#handleSocketClose
···
77
78
return this.#socket.readyState === this.#socket.OPEN
78
79
}
79
80
80
80
-
get peers(): Record<IdentID, PeerState> {
81
81
+
peerStates(): Record<IdentID, PeerState> {
81
82
const states: Record<IdentID, PeerState> = {}
82
83
for (const [identid, peer] of this.#peers) {
83
84
states[identid] = {
···
113
114
114
115
destroy() {
115
116
console.debug('realm connection destroy!')
116
116
-
117
117
-
// disconnect from socket
118
117
if (this.connected) {
119
118
this.#socket.close()
120
119
}
···
158
157
159
158
// handle socket open is the main loop for the sendSocket
160
159
#handleSocketOpen: WebSocket['onopen'] = async () => {
161
161
-
console.debug('realm connection, socket loop open')
162
160
this.#dispatchCustomEvent('wsopen')
163
161
164
162
try {