IRISLIB database
Client Class Reference

Implements a WebSocket client. More...

Inheritance diagram for Client:
Collaboration diagram for Client:

Public Member Functions

_.Library.Status OnClose ()
 Closes the web socket connection from the client.
 
_.Library.Boolean Next (_.Library.Integer pTimeout, _.Library.Boolean pTimedOut)
 Waits for data from the server. More...
 
_.Library.Status Ping (_.Library.String pMessage, _.Library.Integer pTimeout)
 Sends a ping frame to the server. More...
 
_.Library.Status Pong (_.Library.String pMessage)
 Sends an unsolicited pong frame to the server. More...
 
_.Library.Status Send (pContent, _.Library.Integer pFragmentSize)
 Sends a binary or character stream, dynamic object, or string to the server. More...
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 

Public Attributes

 URL
 WebSocket endpoint. More...
 

Private Member Functions

 __EstablishConnection ()
 Makes the initial HTTP request and negotiates the upgrade to WebSocket protocol.
 
_.Library.Status __ValidateProtocolSwitch ()
 Ensures response headers are valid for upgrading to web sockets.
 

Private Attributes

 __AcceptedProtocols
 Accepted protocols (Sec-WebSocket-Protocol request header) More...
 
 __Credentials
 Provides username, password, and SSL configuration. More...
 
 __EventListener
 Handles open, close, message, and error events. More...
 
 __Nonce
 Base64-encoded 16-byte random value provided to the server for validation. More...
 
 __Protocol
 The actual protocol in use (Sec-WebSocket-Protocol response header) More...
 
 __Request
 The HTTP request, wrapping use of the device used for communcation. More...
 

Additional Inherited Members

- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 

Detailed Description

Implements a WebSocket client.


Usage:

  • Implement Net.WebSocket.IEventListener to respond to events (most importantly, receipt of a message).
  • Implement Net.WebSocket.ICredentials to provide a username/password/SSLConfiguration for the connection as needed.
  • Create a new instance of <class>Net.WebSocket.Client</class>, providing a WebSocket URL and instances of the ICredentials and IEventListener implementations.
  • Call <method>Next</method>() to wait for the next message, and <method>Send</method> to send a message.

Member Function Documentation

◆ Next()

_.Library.Boolean Next ( _.Library.Integer  pTimeout,
_.Library.Boolean  pTimedOut 
)

Waits for data from the server.

Returns 1 if the connection remains open, and 0 if the connection is closed or an error occurs.

The event listener will be notified upon receiving a message, or if the connection is closed or an error occurs.
@Argument pTimeout Timeout (in seconds) to wait to receive a message from the server. @Argument pTimedOut True if the read operation timed out.

◆ Ping()

_.Library.Status Ping ( _.Library.String  pMessage,
_.Library.Integer  pTimeout 
)

Sends a ping frame to the server.


Returns $$$NetWebSocketErrPingTimeout if the ping times out
Returns $$$NetWebSocketErrPongInvalid if the pong response is not equal to pMessage
Otherwise, returns $$$OK @Argument pMessage Message to send with the ping @Argument pFragmentSize Timeout (in seconds) to wait to receive a "pong" back from the server.

◆ Pong()

_.Library.Status Pong ( _.Library.String  pMessage)

Sends an unsolicited pong frame to the server.


@Argument pMessage Message to send with the pong

◆ Send()

_.Library.Status Send (   pContent,
_.Library.Integer  pFragmentSize 
)

Sends a binary or character stream, dynamic object, or string to the server.

@Argument pContent Binary or character stream, dynamic object, or string to the server. @Argument pFragmentSize Maximum size (in bytes) to send in a single frame; 0 indicates no maximum.

Member Data Documentation

◆ __AcceptedProtocols

__AcceptedProtocols
private

Accepted protocols (Sec-WebSocket-Protocol request header)

 

◆ __Credentials

__Credentials
private

Provides username, password, and SSL configuration.

 

◆ __EventListener

__EventListener
private

Handles open, close, message, and error events.

 

◆ __Nonce

__Nonce
private

Base64-encoded 16-byte random value provided to the server for validation.

 

◆ __Protocol

__Protocol
private

The actual protocol in use (Sec-WebSocket-Protocol response header)

 

◆ __Request

__Request
private

The HTTP request, wrapping use of the device used for communcation.

 

◆ URL

URL

WebSocket endpoint.