Browse Source
* Clear heartbeat and queue when disconnected * Give clearer error in case configure fails due to a lost connection. Used to throw 'Packet does not exist' * If the queue processing error is due to a lost connection, throw it instead of looping endlessly * In case we send a disconnection event we don't need to also throw * Catch heartbeat errors * Also handle invalid state errors * Handle socket timeouts * Log heartbeat failures * Make linter happy * Transform stream being a singleton prevented reconnection attempts * Adapt tests to not using singleton * Aborting already ends the connectionpull/834/head
committed by
GitHub
11 changed files with 124 additions and 54 deletions
@ -1,16 +1,18 @@ |
|||||
/** |
/** |
||||
* Pads packets with appropriate framing information before writing to the output stream. |
* Pads packets with appropriate framing information before writing to the output stream. |
||||
*/ |
*/ |
||||
export const toDeviceStream: TransformStream<Uint8Array, Uint8Array> = |
export const toDeviceStream: () => TransformStream<Uint8Array, Uint8Array> = |
||||
new TransformStream<Uint8Array, Uint8Array>({ |
() => { |
||||
transform(chunk: Uint8Array, controller): void { |
return new TransformStream<Uint8Array, Uint8Array>({ |
||||
const bufLen = chunk.length; |
transform(chunk: Uint8Array, controller): void { |
||||
const header = new Uint8Array([ |
const bufLen = chunk.length; |
||||
0x94, |
const header = new Uint8Array([ |
||||
0xc3, |
0x94, |
||||
(bufLen >> 8) & 0xff, |
0xc3, |
||||
bufLen & 0xff, |
(bufLen >> 8) & 0xff, |
||||
]); |
bufLen & 0xff, |
||||
controller.enqueue(new Uint8Array([...header, ...chunk])); |
]); |
||||
}, |
controller.enqueue(new Uint8Array([...header, ...chunk])); |
||||
}); |
}, |
||||
|
}); |
||||
|
}; |
||||
|
|||||
Loading…
Reference in new issue