@knowlearning/agents 0.9.83 → 0.9.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agents/browser/root.js
CHANGED
|
@@ -18,7 +18,7 @@ export default options => {
|
|
|
18
18
|
this.close = () => ws.close()
|
|
19
19
|
|
|
20
20
|
ws.onopen = () => this.onopen()
|
|
21
|
-
ws.onmessage = ({ data }) => this.onmessage(data)
|
|
21
|
+
ws.onmessage = ({ data }) => this.onmessage(data.length === 0 ? null : JSON.parse(data))
|
|
22
22
|
ws.onerror = error => this.onerror && this.onerror(error)
|
|
23
23
|
ws.onclose = error => this.onclose && this.onclose(error)
|
|
24
24
|
|
|
@@ -124,13 +124,12 @@ export default function messageQueue({ token, Connection, watchers, states, appl
|
|
|
124
124
|
connection.send({ token: await token(), session })
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
connection.onmessage = async
|
|
127
|
+
connection.onmessage = async message => {
|
|
128
128
|
checkHeartbeat()
|
|
129
|
-
if (
|
|
129
|
+
if (!message) return // heartbeat
|
|
130
130
|
|
|
131
131
|
try {
|
|
132
132
|
log('handling message', disconnected, authed)
|
|
133
|
-
const message = JSON.parse(data)
|
|
134
133
|
log('message', JSON.stringify(message))
|
|
135
134
|
|
|
136
135
|
if (message.error) console.warn('ERROR RESPONSE', message)
|