diff --git a/src/DumbClient.ts b/src/DumbClient.ts index 8602ffd..d8e1c0f 100644 --- a/src/DumbClient.ts +++ b/src/DumbClient.ts @@ -58,7 +58,7 @@ export default class DumbClient extends Emitter { log("forwarding close"); this.emit(DumbClientEvents.Close); }); - this._shell.on(ShellEvents.Packet, (_size, data) => { + this._shell.on(ShellEvents.Packet, (data) => { log("forwarding packet", data); this.emit(DumbClientEvents.Packet, new Packet(data)); }); diff --git a/src/shell/index.ts b/src/shell/index.ts index 2114e36..2559dbb 100644 --- a/src/shell/index.ts +++ b/src/shell/index.ts @@ -34,7 +34,7 @@ export enum ShellEvents { Close = "close" } export type ShellEventArguments = { - [ShellEvents.Packet]: [number, Buffer]; + [ShellEvents.Packet]: [Buffer]; [ShellEvents.Reset]: []; [ShellEvents.Close]: []; }; @@ -56,9 +56,9 @@ export default class Shell extends Emitter { log("forwarding close"); this.emit(ShellEvents.Close); }); - this._stream.on(StreamEvents.Packet, (size, packet) => { + this._stream.on(StreamEvents.Packet, (packet) => { log("forwarding+decoding packet", packet); - this.emit(ShellEvents.Packet, size, this._algorithm.decode(packet)); + this.emit(ShellEvents.Packet, this._algorithm.decode(packet)); }); } diff --git a/src/stream/DirectStream.ts b/src/stream/DirectStream.ts index 6b240b5..cd60002 100644 --- a/src/stream/DirectStream.ts +++ b/src/stream/DirectStream.ts @@ -41,7 +41,7 @@ export type DirectStreamEventArguments = { */ [DirectStreamEvents.Read]: [ControlCharacters.ReadByte, 1, number] | [SizedControlCharacters, number, Buffer]; /** Emitted when an End of Packet is received along with (size, data) parameters. */ - [DirectStreamEvents.Packet]: [number, Buffer]; + [DirectStreamEvents.Packet]: [Buffer]; }; /** @@ -217,7 +217,7 @@ export default class DirectStream extends Emitter { /** Called internally to clear and emit a packet. */ private _emitPacket(): void { debug("triggering packet"); - this.emit(DirectStreamEvents.Packet, this._packetSize, this._packet); + this.emit(DirectStreamEvents.Packet, this._packet); this._packet = Buffer.alloc(0); this._packetSize = 0; } diff --git a/src/stream/index.ts b/src/stream/index.ts index 2936ca7..67731b7 100644 --- a/src/stream/index.ts +++ b/src/stream/index.ts @@ -41,7 +41,7 @@ export type StreamEventArguments = { /** * Fired whenever an End Of Packet is received, with two parameters, size and data. */ - [StreamEvents.Packet]: [number, Buffer]; + [StreamEvents.Packet]: [Buffer]; /** * Fired whenever the remote sends Read Reset. */ @@ -86,9 +86,9 @@ export default class Stream extends Emitter { log("forwarding read", data); this.emit(StreamEvents.Read, data instanceof Buffer ? data : Buffer.from([data])); }); - this._stream.on(DirectStreamEvents.Packet, (size, data) => { + this._stream.on(DirectStreamEvents.Packet, (data) => { log("forwarding packet", data); - this.emit(StreamEvents.Packet, size, data); + this.emit(StreamEvents.Packet, data); }); this._provider.on(IOProviderEvents.Close, () => { log("forwarding close"); diff --git a/src/tests/shell/index.test.ts b/src/tests/shell/index.test.ts index 92595aa..6ff2929 100644 --- a/src/tests/shell/index.test.ts +++ b/src/tests/shell/index.test.ts @@ -74,7 +74,7 @@ describe("Shell", () => { manual.write(Buffer.concat([direct.encode(data), Buffer.from([ControlCharacters.EndOfPacket])])); expect(localPacket).toBeCalledTimes(1); - expect(localPacket).toBeCalledWith(13, data); + expect(localPacket).toBeCalledWith(data); }); describe("close", () => { diff --git a/src/tests/stream/DirectStream.test.ts b/src/tests/stream/DirectStream.test.ts index 12e9a86..b8fdc11 100644 --- a/src/tests/stream/DirectStream.test.ts +++ b/src/tests/stream/DirectStream.test.ts @@ -94,7 +94,7 @@ describe("Stream", () => { expect(onRead).not.toHaveBeenCalled(); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(0, Buffer.alloc(0)); + expect(onPacket).toHaveBeenCalledWith(Buffer.alloc(0)); expect(onReset).not.toHaveBeenCalled(); }); @@ -106,7 +106,7 @@ describe("Stream", () => { expect(onRead).toHaveBeenCalledTimes(1); expect(onRead).toHaveBeenCalledWith(ControlCharacters.ReadByte, 1, 1); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(1, Buffer.from([1])); + expect(onPacket).toHaveBeenCalledWith(Buffer.from([1])); expect(onReset).not.toHaveBeenCalled(); }); @@ -157,7 +157,7 @@ describe("Stream", () => { Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb]) ); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(12, Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb])); + expect(onPacket).toHaveBeenCalledWith(Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb])); expect(onReset).not.toHaveBeenCalled(); }); @@ -179,7 +179,7 @@ describe("Stream", () => { Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb]) ); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(12, Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb])); + expect(onPacket).toHaveBeenCalledWith(Buffer.from([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb])); expect(onReset).not.toHaveBeenCalled(); }); @@ -201,7 +201,7 @@ describe("Stream", () => { Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b]) ); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(12, Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b])); + expect(onPacket).toHaveBeenCalledWith(Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b])); expect(onReset).not.toHaveBeenCalled(); }); @@ -213,7 +213,7 @@ describe("Stream", () => { expect(onRead).toHaveBeenCalledTimes(1); expect(onRead).toHaveBeenCalledWith(ControlCharacters.ReadByte, 1, 0); expect(onPacket).toHaveBeenCalledTimes(1); - expect(onPacket).toHaveBeenCalledWith(0, Buffer.alloc(0)); + expect(onPacket).toHaveBeenCalledWith(Buffer.alloc(0)); expect(onReset).toHaveBeenCalledTimes(1); expect(onReset).toHaveBeenCalledWith(); }); diff --git a/src/tests/stream/index.test.ts b/src/tests/stream/index.test.ts index 4fff3e9..2643032 100644 --- a/src/tests/stream/index.test.ts +++ b/src/tests/stream/index.test.ts @@ -122,7 +122,7 @@ describe("Stream", () => { ); expect(onPacket).toBeCalledTimes(1); - expect(onPacket).toBeCalledWith(13, Buffer.from("Hello, World!")); + expect(onPacket).toBeCalledWith(Buffer.from("Hello, World!")); }); it("emits Reset when a remote read reset is encountered and does discard the packet so far", () => { @@ -164,7 +164,7 @@ describe("Stream", () => { expect(onReset).toBeCalledTimes(1); expect(onPacket).toBeCalledTimes(1); - expect(onPacket).toBeCalledWith(0, Buffer.alloc(0)); + expect(onPacket).toBeCalledWith(Buffer.alloc(0)); expect(onRead).toBeCalledTimes(2); });