Clients - http : WebSocketClient

Represents a WebSocket client endpoint.

Constructor

__init

(string url, WebSocketClientEndpointConfig? config)

Remote Methods

Methods

Fields

  • negotiatedSubProtocol string
  • The subprotocols that are negotiated with the server

  • isSecure boolean false
  • true if the connection is secure

  • isOpen boolean false
  • true if the connection is open

  • response Response BLangTypeInit: new null ([])
  • Represents the HTTP response

  • attributes map {}
  • A map to store connection related attributes

pushText

(string | json | xml | boolean | int | float | byte | byte[] data, boolean finalFrame)

returns error?

Push text to the connection.

Parameters

  • finalFrame boolean - true
  • Set to true if this is a final frame of a (long) message

  • Return Type

    (error?)
  • error if an error occurs when sending

pushBinary

(byte[] data, boolean finalFrame)

returns error?

Push binary data to the connection.

Parameters

  • data byte[]
  • Binary data to be sent

  • finalFrame boolean - true
  • Set to true if this is a final frame of a (long) message

  • Return Type

    (error?)
  • error if an error occurs when sending

ping

(byte[] data)

returns error?

Ping the connection.

Parameters

  • data byte[]
  • Binary data to be sent.

  • Return Type

    (error?)
  • error if an error occurs when sending

pong

(byte[] data)

returns error?

Send pong message to the connection.

Parameters

  • data byte[]
  • Binary data to be sent

  • Return Type

    (error?)
  • error if an error occurs when sending

close

(int? statusCode, string? reason, int timeoutInSecs)

returns error?

Close the connection.

Parameters

  • statusCode int? - 1000
  • Status code for closing the connection

  • reason string? - ()
  • Reason for closing the connection

  • timeoutInSecs int - 60
  • Time to wait for the close frame to be received from the remote endpoint before closing the connection. If the timeout exceeds, then the connection is terminated even though a close frame is not received from the remote endpoint. If the value < 0 (e.g., -1), then the connection waits until a close frame is received. If WebSocket frame is received from the remote endpoint, within waiting period the connection is terminated immediately.

  • Return Type

    (error?)
  • error if an error occurs when sending

ready

()

returns error?

Called when the endpoint is ready to receive messages. Can be called only once per endpoint. For the WebSocketListener can be called only in upgrade or onOpen resources.

  • Return Type

    (error?)
  • error if an error occurs when sending

initEndpoint

Initializes the endpoint.