@refinio/one.models
    Preparing search index...

    This class is a wrapper for web sockets, that allows to receive messages with async / await instead of using callbacks (onmessage onopen ...)

    It also has a on('message') event, because sometimes you just need it. When you solely use the event based interface, and don't use the waitForMessage functions, then you need to set disableWaitForMessage to true, because otherwise you will get an error that you didn't collect incoming messages with waitFor... functions.

    Implements

    Index

    Constructors

    • Construct a new connection - at the moment based on WebSockets

      Parameters

      • webSocket: WebSocket
      • defaultOpenTimeout: number = Number.POSITIVE_INFINITY

      Returns default

    Properties

    id: number = ++Connection.idCounter
    onMessage: OEvent<(message: string | Uint8Array<ArrayBufferLike>) => void> = ...

    Event is emitted when a new message is received.

    state: StateMachine<"closed" | "connecting" | "open", "open" | "close">

    Accessors

    • get bufferedAmount(): number

      Chum streams use the websocket bufferedAmount number to control how fast the streams provide data to the websocket stream.

      Returns number

    Methods

    • Add a plugin to the connection.

      Parameters

      • plugin: default
      • Optionaloptions: { after?: string; before?: string }

      Returns void

    • Closes the connection.

      This function waits for the other side to acknowledge.

      Parameters

      • Optionalreason: string

        Reason for timeout

      Returns void

    • Wait for the socket to be open.

      Parameters

      • Optionaltimeout: number

      Returns Promise<void>