Class LabGuiWebsocket

Hierarchy

  • LabGuiWebsocket

Constructors

Properties

forcedClose: boolean = false
onclose: ((event: Event) => void) = ...

Type declaration

    • (event: Event): void
    • Parameters

      • event: Event

      Returns void

onconnecting: (() => void) = ...

Type declaration

    • (): void
    • Returns void

onerror: ((event: Event) => void) = ...

Type declaration

    • (event: Event): void
    • Parameters

      • event: Event

      Returns void

onopen: ((event: Event) => void) = ...

Type declaration

    • (event: Event): void
    • Parameters

      • event: Event

      Returns void

protocols: string[]
readyState: number
reconnectAttempts: number
settings: LabGuiWebsocketSettings = ...
timedOut: boolean = false
url: string
ws: null | WebSocket = null

Accessors

  • get connectionState(): number
  • Returns the current readyState and is only used for testing

    Returns number

  • get wsInstance(): null | WebSocket
  • Returns the used WebSocket instance and is only used for testing

    Returns null | WebSocket

Methods

  • Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing. Returns boolean, whether websocket was FORCEFULLY closed.

    Returns boolean

  • Connects the WebSocket to the Server at the given url. This method get automatically executed at instance creation, if automaticOpen=false is passes with the settings.

    Parameters

    • reconnectAttempt: boolean

    Returns void

  • Takes the response from the Server (which is expected to be a JSON sting) and return the object representation of that data.

    Parameters

    • response: MessageEvent<any>

    Returns object

  • Private logging method which only logs if the setting 'debug' is set to true

    Parameters

    • Rest ...args: any[]

    Returns void

  • Dummy method which is supposed to be overwritten

    Parameters

    • msgObject: object

    Returns void

  • Action to be triggered when the Server send data to the client. The sent data is expected to be a JSON sting. The object generated from that response is than passed to message_logic which is supposed to be overwritten and do all the business logic.

    Parameters

    • response: MessageEvent<any>

    Returns void

  • Transmits data to the server over the WebSocket connection.

    Parameters

    • data: string | SendData

      a text string or SendData to send to the server.

    Returns void

Generated using TypeDoc