Home > Class Reference > %SYS namespace > %Net.WebSocket.Client


class %Net.WebSocket.Client extends %Library.RegisteredObject

Implements a WebSocket client.

Property Inventory (Including Private)

Method Inventory (Including Private)

Properties (Including Private)

property AcceptedProtocols as %String [ Private ];
Accepted protocols (Sec-WebSocket-Protocol request header)
Property methods: AcceptedProtocolsDisplayToLogical(), AcceptedProtocolsGet(), AcceptedProtocolsIsValid(), AcceptedProtocolsLogicalToDisplay(), AcceptedProtocolsLogicalToOdbc(), AcceptedProtocolsNormalize(), AcceptedProtocolsSet()
property Credentials as %Net.WebSocket.ICredentials [ Private ];
Provides username, password, and SSL configuration
Property methods: CredentialsGet(), CredentialsGetSwizzled(), CredentialsIsValid(), CredentialsNewObject(), CredentialsSet()
property EventListener as %Net.WebSocket.IEventListener [ Private ];
Handles open, close, message, and error events
Property methods: EventListenerGet(), EventListenerGetSwizzled(), EventListenerIsValid(), EventListenerNewObject(), EventListenerSet()
property Nonce as %String [ Private , InitialExpression = $System.Encryption.Base64Encode($System.Encryption.GenCryptRand(16)) ];
Base64-encoded 16-byte random value provided to the server for validation
Property methods: NonceDisplayToLogical(), NonceGet(), NonceIsValid(), NonceLogicalToDisplay(), NonceLogicalToOdbc(), NonceNormalize(), NonceSet()
property Protocol as %String [ Private ];
The actual protocol in use (Sec-WebSocket-Protocol response header)
Property methods: ProtocolDisplayToLogical(), ProtocolGet(), ProtocolIsValid(), ProtocolLogicalToDisplay(), ProtocolLogicalToOdbc(), ProtocolNormalize(), ProtocolSet()
property Request as %Net.HttpRequest [ Private ];
The HTTP request, wrapping use of the device used for communcation
Property methods: RequestGet(), RequestGetSwizzled(), RequestIsValid(), RequestNewObject(), RequestSet()
property URL as %String [ ReadOnly ];
WebSocket endpoint
Property methods: URLDisplayToLogical(), URLGet(), URLIsValid(), URLLogicalToDisplay(), URLLogicalToOdbc(), URLNormalize()

Methods (Including Private)

private method %OnClose() as %Status [ Language = objectscript ]
Closes the web socket connection from the client.
method %OnNew(pURL As %String, pCredentials As %Net.WebSocket.ICredentials = $$$NULLOREF, pEventListener As %Net.WebSocket.IEventListener = $$$NULLOREF, pAcceptedProtocols As %String = "", pRequest As %Net.HttpRequest = $$$NULLOREF) as %Status [ Language = objectscript ]
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

private method EstablishConnection() [ Language = objectscript ]
Makes the initial HTTP request and negotiates the upgrade to WebSocket protocol
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.
@API.Method @Argument pTimeout Timeout (in seconds) to wait to receive a message from the server.
method Ping(pMessage As %String, pTimeout As %Integer = 10) as %Status [ Language = objectscript ]
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 @API.Method @Argument pMessage Message to send with the ping @Argument pFragmentSize Timeout (in seconds) to wait to receive a "pong" back from the server.
method Pong(pMessage As %String) as %Status [ Language = objectscript ]
Sends an *unsolicited* pong frame to the server.
@API.Method @Argument pMessage Message to send with the pong
method Send(pContent, pFragmentSize As %Integer = 0) as %Status [ Language = objectscript ]
Sends a binary or character stream, dynamic object, or string to the server. @API.Method @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.
private method ValidateProtocolSwitch() as %Status [ Language = objectscript ]
Ensures response headers are valid for upgrading to web sockets

Inherited Members

Inherited Methods (Including Private)