Home > Class Reference > ENSLIB namespace > %CSP.WebSocket

%CSP.WebSocket

class %CSP.WebSocket extends %Library.RegisteredObject, %CSP.Page

The %CSP.WebSocket object serves as an event handler for communication between client and server using the WebSocket protocol (RFC 6455). All WebSocket servers derive from %CSP.WebSocket.

Property Inventory (Including Private)

Method Inventory (Including Private)

Parameters

parameter NOCHARSETCONVERT = 1;
Inherited description: Specifies if we wish to turn off charset conversion for this page. Normally CSP uses the tables built into Cache to convert between different charset's, however if you do not have a charset available you may wish to turn this off to avoid getting the error page saying that this charset is not installed. Then the data will be output and read in using RAW mode. This can be overridden using the <CSP:CONTENT NOCHARSETCONVERT=1> tag, or by setting the %response.NoCharSetConvert property in the OnPreHTTP() method.
parameter UseSession = 1;
Inherited description: This parameter controls the CSP session support. By default CSP will use a persistent session which holds a license until the session is ended or times out. If you override this then this CSP page will use a transient session which is never persisted.

Properties (Including Private)

property AtEnd as %Boolean [ InitialExpression = 1 ];
The AtEnd property is set to true (1) when, during a read, the WebSocket server has reached the end of the current data frame.
Property methods: AtEndDisplayToLogical(), AtEndGet(), AtEndIsValid(), AtEndLogicalToDisplay(), AtEndNormalize(), AtEndSet()
property BinaryData as %Boolean [ InitialExpression = 0 ];
This property determines whether the data streams transmitted between the client and server should be treated as binary. The default setting is to treat the incoming and outgoing data as UTF-8 encoded text.

This property may be set to one of the following:
  • BinaryData=0 - UTF-8 encoded text.
  • BinaryData=1 - Binary Data.
Property methods: BinaryDataDisplayToLogical(), BinaryDataGet(), BinaryDataIsValid(), BinaryDataLogicalToDisplay(), BinaryDataNormalize(), BinaryDataSet()
property BytesAvailable as %Integer [ Private , InitialExpression = 0 ];
The amount of client data waiting to be read.
Property methods: BytesAvailableDisplayToLogical(), BytesAvailableGet(), BytesAvailableIsValid(), BytesAvailableLogicalToDisplay(), BytesAvailableNormalize(), BytesAvailableSet()
property DataFrameType as %Integer [ Private , InitialExpression = 0 ];
The type of the Data Frame waiting to be read.
Property methods: DataFrameTypeDisplayToLogical(), DataFrameTypeGet(), DataFrameTypeIsValid(), DataFrameTypeLogicalToDisplay(), DataFrameTypeNormalize(), DataFrameTypeSet()
property GWClientAddress as %String;
The address through which a WebSocket operating asynchronously (SharedConnection=1) can communicate with the hosting CSP Gateway.
Property methods: GWClientAddressDisplayToLogical(), GWClientAddressGet(), GWClientAddressIsValid(), GWClientAddressLogicalToDisplay(), GWClientAddressLogicalToOdbc(), GWClientAddressNormalize(), GWClientAddressSet()
property NoDataFraming as %Boolean [ InitialExpression = 0 ];
This property determines whether formal data framing should occur between the CSP Gateway and Cache
  • NoDataFraming=0 - Use the READ and WRITE methods in this class to manage I/O with the WebSocket.
  • NoDataFraming=1 - Use the basic Cache READ and WRITE commands to manage I/O with the WebSocket (SharedConnection cannot be set with this mode).
Property methods: NoDataFramingDisplayToLogical(), NoDataFramingGet(), NoDataFramingIsValid(), NoDataFramingLogicalToDisplay(), NoDataFramingNormalize(), NoDataFramingSet()
property SessionId as %String;
The CSP Session ID from which this WebSocket was created.
Property methods: SessionIdDisplayToLogical(), SessionIdGet(), SessionIdIsValid(), SessionIdLogicalToDisplay(), SessionIdLogicalToOdbc(), SessionIdNormalize(), SessionIdSet()
property SharedConnection as %Boolean [ InitialExpression = 0 ];
This property determines whether the communication between the client and WebSocket server should be over a dedicated Gateway conection or over a pool of shared connections. It may be set to one of the following:
  • SharedConnection=0 - The WebSocket server communicates with the client via a dedicated Gateway connection. In this mode of operation the hosting connection is effectively 'private' to the application session.
  • SharedConnection=1 - The WebSocket server communicates asynchronously with the client via a fixed number of shared Gateway connections.
Property methods: SharedConnectionDisplayToLogical(), SharedConnectionGet(), SharedConnectionIsValid(), SharedConnectionLogicalToDisplay(), SharedConnectionNormalize(), SharedConnectionSet()
property WSInitStatus as %Integer [ Private , InitialExpression = 0 ];
The internal initialization status for the WebSocket.
Property methods: WSInitStatusDisplayToLogical(), WSInitStatusGet(), WSInitStatusIsValid(), WSInitStatusLogicalToDisplay(), WSInitStatusNormalize(), WSInitStatusSet()
property WebSocketID as %String;
The unique identity of this WebSocket.
Property methods: WebSocketIDDisplayToLogical(), WebSocketIDGet(), WebSocketIDIsValid(), WebSocketIDLogicalToDisplay(), WebSocketIDLogicalToOdbc(), WebSocketIDNormalize(), WebSocketIDSet()

Methods (Including Private)

private final method DeleteServer() as %Status
Internal method to delete the WebSocket Server.
method EndServer() as %Status
Gracefully terminate the WebSocket Server.
method Initialize(WebSocketID As %String = "", GWClientAddress As %String = "") as %Status
Internal method to initialize the WebSocket Class.
method InitializeServer() as %Status
Internal method to initialize the WebSocket Server.
method OnClientMessage(data As %String = "", close As %Integer) as %Status
Event handler for the ClientMessage event: this method is only relevant to WebSockets operating in Asynchronous mode. In other words WebSockets for which the SharedConnection flag is set. If OnClientMessage() successfully processes the client message it must return with 1.
method OnPostServer() as %Status
Event handler for the PostServer event: this is invoked after closing the WebSockets Server.
method OnPreServer() as %Status
Event handler for the PreServer event: this is invoked before starting the WebSockets Server. Changes to the SharedConnection flag must be made here.
method OpenServer(WebSocketID As %String = "") as %Status