Options
All
  • Public
  • Public/Protected
  • All
Menu

A socketit socket, adapted for use in the browser.

Hierarchy

  • default

Index

Constructors

Methods

Constructors

constructor

  • new default(socket: WebSocket): default
  • A socketit socket.

    Parameters

    • socket: WebSocket

      The socket to extend.

      const {Socket} = require('socketit')
      const ws = new WebSocket("ws://someurl.com")
      const socket = new Socket(ws)
      

    Returns default

Methods

handle

  • handle(reqId: string, handler: (req: unknown) => unknown): void
  • Handle a request.

    Parameters

    • reqId: string

      The request ID to handle.

    • handler: (req: unknown) => unknown

      The function to be called when the request is called.

        • (req: unknown): unknown
        • Parameters

          • req: unknown

          Returns unknown

    Returns void

request

  • request(reqId: string, requestData?: unknown): Promise<unknown>
  • Send a request and await the results.

    Parameters

    • reqId: string

      The ID of the request.

    • Optional requestData: unknown

      Optional data to be passed along with the request.

    Returns Promise<unknown>

    A promise that resolves with the response.

stream

  • stream(id: string): Duplex
  • Get a duplex stream with an ID.

    Parameters

    • id: string

      The id of the stream.

    Returns Duplex

    A Duplex stream that is piped over WebSockets to the other party.

Generated using TypeDoc