A WebSocketLike for LockstepClient's create option: sent holds what the client sent, receive(message) delivers a server message as JSON (receiveRaw delivers text as is), and close() fires onclose.
WebSocketLike
LockstepClient
create
sent
receive(message)
receiveRaw
close()
onclose
import { LockstepClient } from '@datamoc/mwg/core';import { FakeSocket } from '@datamoc/mwg/testing';const socket = new FakeSocket();const client = new LockstepClient({ url: 'wss://example.test', create: () => socket });client.connect();socket.receive({ type: 'welcome', id: 'p1' }); Copy
import { LockstepClient } from '@datamoc/mwg/core';import { FakeSocket } from '@datamoc/mwg/testing';const socket = new FakeSocket();const client = new LockstepClient({ url: 'wss://example.test', create: () => socket });client.connect();socket.receive({ type: 'welcome', id: 'p1' });
Readonly
A
WebSocketLikeforLockstepClient'screateoption:sentholds what the client sent,receive(message)delivers a server message as JSON (receiveRawdelivers text as is), andclose()firesonclose.Example