WebSocket stabiler gemacht mit Puffern beim Broker
This commit is contained in:
1 parent
12523ddd0a
commit
c793e8b16d
10 files changed
+533
-37
No files matched your search
@@ -125,7 +125,13 @@
|
||||
adminSocket = ws;
|
||||
|
||||
ws.addEventListener('open', () => {
|
||||
ws.send(JSON.stringify({code: 0, msg: data.token}));
|
||||
ws.send(JSON.stringify({
|
||||
code: 0,
|
||||
msg: {
|
||||
token: data.token,
|
||||
session_id: window.CMBNET_CLIENT_SESSION_ID || ''
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
ws.addEventListener('message', event => {
|
||||
@@ -135,6 +141,12 @@
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
if (Number(message.code) === 1) {
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify({code: 2, msg: 'pong'}));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Number(message.code) !== 99) return;
|
||||
const text = typeof message.msg === 'string'
|
||||
? message.msg
|
||||
|
||||
Reference in new issue
Block a user