Class Reference
IRIS for UNIX 2019.2
InterSystems: The power behind what matters   
Documentation  Search
  [ENSLIB] >  [%CSP] >  [WebSocket]
Private  Storage   

class %CSP.WebSocket extends %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.

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
2 12 17


Summary

Properties
AtEnd BinaryData GWClientAddress NoDataFraming
SessionId SharedConnection WebSocketID

Methods
%AddToSaveSet %ClassIsLatestVersion %ClassName %ConstructClone
%DispatchClassMethod %DispatchGetModified %DispatchGetProperty %DispatchMethod
%DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty %Extends
%GetParameter %IsA %IsModified %New
%NormalizeObject %ObjectModified %OriginalNamespace %PackageName
%RemoveFromSaveSet %SerializeObject %SetModified %ValidateObject
ConvertParameter Decrypt Encrypt EndServer
EscapeHTML EscapeURL HyperEventCall HyperEventHead
Include Initialize InitializeServer InsertHiddenField
InsertHiddenFields IsPrivate Link OnClientMessage
OnHTTPHeader OnPage OnPageError OnPostHTTP
OnPostHyperEvent OnPostServer OnPreHTTP OnPreHyperEvent
OnPreServer OpenServer QuoteJS Read
RewriteURL Server ShowError StartTimer
StopTimer ThrowError UnescapeHTML UnescapeURL
Write

Subclasses
%Atelier.v1.XDebugAgent %Atelier.v2.XDebugAgent

Parameters

• parameter NOCHARSETCONVERT = 1;
Specifies if we wish to turn off charset conversion for this page. Normally CSP uses the tables built into InterSystems IRIS 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 = 0;
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

• 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 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 GWClientAddress as %String;
The address through which a WebSocket operating asynchronously (SharedConnection=1) can communicate with the hosting CSP Gateway.
• property NoDataFraming as %Boolean [ InitialExpression = 0 ];
This property determines whether formal data framing should occur between the Web Gateway and InterSystems IRIS
  • NoDataFraming=0 - Use the READ and WRITE methods in this class to manage I/O with the WebSocket.
  • NoDataFraming=1 - Use the basic ObjectScript READ and WRITE commands to manage I/O with the WebSocket (SharedConnection cannot be set with this mode).
• property SessionId as %String;
The CSP Session ID from which this WebSocket was created.
• 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 WebSocketID as %String;
The unique identity of this WebSocket.

Methods

• 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 $$$OK
• 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
Method to open an existing WebSocket Server. Only a WebSocket operating asynchronously (SharedConnection=1) can be accessed using this method.
• method Read(ByRef len As %Integer = 32656, ByRef sc As %Status, timeout As %Integer = 86400) as %String
Reads up to len characters from the client. If the call is successful the status (sc) will be returned as $$$OK, otherwise an error code of $$$CSPWebSocketTimeout indicates a timeout and $$$CSPWebSocketClosed indicates that the client has terminated the WebSocket.
• method Server() as %Status
The WebSocket Server. Use the Read and Write methods to receive data from, and send data to, the client. Call the EndServer method to gracefully terminate the WebSocket Server. A WebSocket operating asynchronously (SharedConnection=1) can exit this method (using Quit) and subsequently open the WebSocket using the OpenServer method.
• method Write(data As %String) as %Status
Write to the client.


Copyright (c) 2019 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.