refactor websocket layer

This commit is contained in:
seavor 2026-04-16 00:23:22 -05:00
parent 4f68190a25
commit f0c3581d26
9 changed files with 87 additions and 142 deletions

View file

@ -91,11 +91,14 @@ describe('ProtobufService', () => {
expect(mockSocket.send).toHaveBeenCalled();
});
it('does not send when socket is not OPEN', () => {
it('does not register callback or increment cmdId when transport is closed', () => {
const service = new ProtobufService(mockSocket);
mockSocket.isOpen.mockReturnValue(false);
service.sendCommand(create(Data.CommandContainerSchema), vi.fn());
const cb = vi.fn();
service.sendCommand(create(Data.CommandContainerSchema), cb);
expect(mockSocket.send).not.toHaveBeenCalled();
expect((service as ProtobufInternal).cmdId).toBe(0);
expect((service as ProtobufInternal).pendingCommands.size).toBe(0);
});
});