fix packet repetition
This commit is contained in:
Родитель
83a7dc3827
Коммит
ac2b901c64
|
@ -94,6 +94,7 @@ export async function devToolsCommand(
|
||||||
disableRoleManager: true,
|
disableRoleManager: true,
|
||||||
proxy: true,
|
proxy: true,
|
||||||
})
|
})
|
||||||
|
bus.passive = true
|
||||||
bus.on(ERROR, e => error(e))
|
bus.on(ERROR, e => error(e))
|
||||||
bus.addBridge(bridge)
|
bus.addBridge(bridge)
|
||||||
const processPacket = (message: Buffer | Uint8Array, sender: string) => {
|
const processPacket = (message: Buffer | Uint8Array, sender: string) => {
|
||||||
|
@ -118,7 +119,6 @@ export async function devToolsCommand(
|
||||||
log(`client: connected (${sender}, ${clients.length} clients)`)
|
log(`client: connected (${sender}, ${clients.length} clients)`)
|
||||||
client.on("message", event => {
|
client.on("message", event => {
|
||||||
const { data } = event
|
const { data } = event
|
||||||
clients.filter(c => c !== client).forEach(c => c.send(data))
|
|
||||||
processPacket(data, sender)
|
processPacket(data, sender)
|
||||||
})
|
})
|
||||||
client.on("close", () => removeClient(client))
|
client.on("close", () => removeClient(client))
|
||||||
|
@ -158,10 +158,6 @@ export async function devToolsCommand(
|
||||||
const pkt = buf.slice(1, endp)
|
const pkt = buf.slice(1, endp)
|
||||||
if (buf.length > endp) buf = buf.slice(endp)
|
if (buf.length > endp) buf = buf.slice(endp)
|
||||||
else buf = null
|
else buf = null
|
||||||
clients
|
|
||||||
.filter(c => c !== client)
|
|
||||||
// this should really be pkt.buffer to get ArrayBuffer but faye-websocket doesn't like that
|
|
||||||
.forEach(c => c.send(Buffer.from(pkt)))
|
|
||||||
processPacket(pkt, sender)
|
processPacket(pkt, sender)
|
||||||
} else {
|
} else {
|
||||||
acc = buf
|
acc = buf
|
||||||
|
|
Загрузка…
Ссылка в новой задаче