Client: Caller

Represents a WebSocket caller.

Remote Methods

writeTextMessage

Pushes text to the connection.

writeBinaryMessage

Pushes binary data to the connection.

ping

Pings the connection.

pong

Sends a pong message to the connection.

close

Closes the connection.

Methods

setAttribute

Sets a connection related attribute.

getAttribute

Gets connection related attribute if any.

removeAttribute

Removes connection related attribute if any.

getConnectionId

Gives the connection id associated with this connection.

getNegotiatedSubProtocol

Gives the subprotocol if any that is negotiated with the client.

isSecure

Gives the secured status of the connection.

isOpen

Gives the open or closed status of the connection.

writeTextMessage

function writeTextMessage(string data) returns Error?
Isolated Function
Remote Function

Pushes text to the connection. If an error occurs while sending the text message to the connection, that message will be lost.

Parameters

Return Type

(Error?)

An error if an error occurs when sending

writeBinaryMessage

function writeBinaryMessage(byte[ ] data) returns Error?
Isolated Function
Remote Function

Pushes binary data to the connection. If an error occurs while sending the binary message to the connection, that message will be lost.

Parameters

  • data byte[ ]
  • Binary data to be sent

Return Type

(Error?)

An error if an error occurs when sending

ping

function ping(byte[ ] data) returns Error?
Isolated Function
Remote Function

Pings the connection. If an error occurs while sending the ping frame to the server, that frame will be lost.

Parameters

  • data byte[ ]
  • Binary data to be sent

Return Type

(Error?)

An error if an error occurs when sending

pong

function pong(byte[ ] data) returns Error?
Isolated Function
Remote Function

Sends a pong message to the connection. If an error occurs while sending the pong frame to the connection, that frame will be lost.

Parameters

  • data byte[ ]
  • Binary data to be sent

Return Type

(Error?)

An error if an error occurs when sending

close

function close(int? statusCode, string? reason, decimal timeout) returns Error?
Isolated Function
Remote Function

Closes the connection.

Parameters

  • statusCode int? (default 1000)
  • Status code for closing the connection

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

  • timeout decimal (default 60)
  • Time to wait (in seconds) 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 the waiting period, the connection is terminated immediately.

Return Type

(Error?)

An error if an error occurs when sending

setAttribute

function setAttribute(string key, any value)
Isolated Function

Sets a connection related attribute.

Parameters

  • key string
  • The key, which identifies the attribute

  • value any
  • The value of the attribute

getAttribute

function getAttribute(string key) returns any
Isolated Function

Gets connection related attribute if any.

Parameters

  • key string
  • The key to identify the attribute

Return Type

(any)

The attribute related to the given key or nil

removeAttribute

function removeAttribute(string key) returns any
Isolated Function

Removes connection related attribute if any.

Parameters

  • key string
  • The key to identify the attribute

Return Type

(any)

The attribute related to the given key or nil

getConnectionId

function getConnectionId() returns string
Isolated Function

Gives the connection id associated with this connection.

Return Type

(string)

The unique ID associated with the connection

getNegotiatedSubProtocol

function getNegotiatedSubProtocol() returns string?
Isolated Function

Gives the subprotocol if any that is negotiated with the client.

Return Type

(string?)

The subprotocol if any negotiated with the client or nil

isSecure

function isSecure() returns boolean
Isolated Function

Gives the secured status of the connection.

Return Type

(boolean)

true if the connection is secure

isOpen

function isOpen() returns boolean
Isolated Function

Gives the open or closed status of the connection.

Return Type

(boolean)

true if the connection is open