Learn more about WebSocket on Wikipedia
SendUpgrade
method on received HTTP Request
object, for example:SendUpgrade
is called and WebSocket object is available, it can immediately be used to perform sends and other operations allowed on WebSocket.WebSocket.ToUInt64()
, in opposite, to create a WebSocket object just pass the UInt64 ID to WebSocket constructor:SendUpgrade
method is called, the approving WebSocket upgrade HTTP Response is sent immediately. To be able to get the WebSocket ID before calling SendUpgrade
, call the UInt64 Request.GetWebSocketId()
.SendUpgrade
method on Request has the following signature:groupName
: string identifying WebSocket "group" on which subsequent events for this WebSocket should arrive.cookies
: Cookies that should be set on returned WebSocket upgrade HTTP response.headers
: Custom headers that should be set on returned WebSocket upgrade HTTP response.session
: a session object that is attached to this WebSocket in subsequent events.ToUInt64()
), and of course, perform data sends and disconnect.Handle.WebSocket
method should be used, for example:Text
and the only registered handler is for Binary
then WebSocket connection will be closed with a type: WS_CLOSE_CANT_ACCEPT_DATA
. Same applies for vice-versa scenario.Handle.WebSocketDisconnect
method should be used, for example:WebSocket
object contains the following notable methods:isText
parameter you can specify if your WebSocket data should be sent as Text
or Binary
frame (see RFC6455)Response.ConnectionFlags
parameter is used to manipulate corresponding WebSocket connection: for example, if you want to close the connection with client or send data and then close the connection. Please see section about handling responses for more information on Response.ConnectionFlags
.Send
) will actually be performed is not guaranteed to be the same as the order in which they were initiated.UInt64 ToUInt64()
: identifier that represents the WebSocket, normally used for storage in user code.IAppsSession Session
: session object that was initially attached on WebSocket if any.static WebSocket Current
: static object identifying currently active WebSocket.enum WebSocketCloseCodes
: list of available WebSocket disconnect codes, according to RFC6455.Boolean IsDead()
: checks if WebSocket is already disconnected or invalid.Session
object contains the reference to the last active WebSocket: ActiveWebsocket
, which is associated with this session. ActiveWebsocket
however can be null
when session has no WebSocket attached to it.