Datalayer VS Code Extension - v0.0.9
    Preparing search index...

    Fake WebSocket implementation that proxies through postMessage. Implements the standard WebSocket API but communicates with the VS Code extension instead of directly connecting to a server.

    Hierarchy

    • EventTarget
      • ProxiedWebSocket
    Index

    Constructors

    Properties

    _disposable: { dispose(): void }

    Disposable for cleaning up message handlers

    _readyState: number

    Current connection state

    binaryType: BinaryType

    Binary data type for received messages

    bufferedAmount: number = 0

    Amount of buffered data waiting to be sent

    clientId: string

    Unique identifier for this WebSocket instance

    CLOSED: 3

    WebSocket connection is closed

    CLOSING: 2

    WebSocket connection is closing

    CONNECTING: 0

    WebSocket is connecting

    extensions: string = ""

    Extensions in use

    listeners: Map<string, Set<(...args: unknown[]) => void>> = ...

    Map of event type to listener functions

    OPEN: 1

    WebSocket connection is open and ready

    protocol: string

    Subprotocol in use

    url: string

    URL of the WebSocket endpoint

    _clientCounter: number = 0

    Counter for generating unique client IDs

    CLOSED: 3

    WebSocket connection is closed

    CLOSING: 2

    WebSocket connection is closing

    CONNECTING: 0

    WebSocket is connecting

    OPEN: 1

    WebSocket connection is open and ready

    Accessors

    • get onclose(): (this: WebSocket, ev: CloseEvent) => unknown

      Get the close event handler callback.

      Returns (this: WebSocket, ev: CloseEvent) => unknown

    • set onclose(listener: (...args: unknown[]) => void): void

      Set the close event handler callback.

      Parameters

      • listener: (...args: unknown[]) => void

        The callback function to invoke when the connection closes

      Returns void

    • get onerror(): (this: WebSocket, ev: Event) => unknown

      Get the error event handler callback.

      Returns (this: WebSocket, ev: Event) => unknown

    • set onerror(listener: (...args: unknown[]) => void): void

      Set the error event handler callback.

      Parameters

      • listener: (...args: unknown[]) => void

        The callback function to invoke when an error occurs

      Returns void

    • get onmessage(): (this: WebSocket, ev: MessageEvent) => unknown

      Get the message event handler callback.

      Returns (this: WebSocket, ev: MessageEvent) => unknown

    • set onmessage(listener: (...args: unknown[]) => void): void

      Set the message event handler callback.

      Parameters

      • listener: (...args: unknown[]) => void

        The callback function to invoke when a message is received

      Returns void

    • get onopen(): (this: WebSocket, ev: Event) => unknown

      Get the open event handler callback.

      Returns (this: WebSocket, ev: Event) => unknown

    • set onopen(listener: (...args: unknown[]) => void): void

      Set the open event handler callback.

      Parameters

      • listener: (...args: unknown[]) => void

        The callback function to invoke when the connection opens

      Returns void

    Methods

    • Private

      Handle incoming messages from the extension. Routes WebSocket messages (open, message, close) to appropriate handlers.

      Parameters

      Returns boolean

      True if the message was processed, false otherwise

    • Register a listener function for a specific event type. The listener can later be invoked via the dispatchEvent method.

      Parameters

      • type: string

        The type of event (e.g., 'open', 'message', 'close', 'error')

      • listener: (...args: unknown[]) => void

        Callback function to invoke when an event of this type is dispatched

      Returns void

    • Close the WebSocket connection.

      Parameters

      • Optionalcode: number

        Optional close code (1000 or 3000-4999)

      • Optionalreason: string

        Optional human-readable close reason

      Returns void

      TypeError if the close code is invalid

      SyntaxError if the close reason is too long

    • Dispatch an event to all registered listeners of that event type. Each listener is invoked with the event as the first argument, or with custom arguments if provided.

      Parameters

      • event: Event

        The event object to dispatch

      • ...customArguments: unknown[]

        Optional custom arguments to pass to listeners instead of the event

      Returns boolean

      True if listeners were found and invoked, false otherwise

    • Unregister a listener function for a specific event type. The listener will no longer be invoked when events of this type are dispatched.

      Parameters

      • type: string

        The type of event (e.g., 'open', 'message', 'close', 'error')

      • listener: (...args: unknown[]) => void

        The callback function to remove

      Returns void

    • Send data through the WebSocket connection.

      Parameters

      • data: unknown

        The data to send (string, Blob, or ArrayBuffer)

      Returns void

      Error if the WebSocket is in CLOSING or CLOSED state