mwg API
    Preparing search index...

    Class FakeSocket

    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.

    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' });

    Implements

    Index
    onclose: ((event: unknown) => void) | null = null
    onerror: ((event: unknown) => void) | null = null
    onmessage: ((event: { data: string }) => void) | null = null
    onopen: ((event: unknown) => void) | null = null
    readyState: number = 1
    sent: string[] = []