Back to product page

WebSocketConnectEvent event


Fires when request for WebSocket connection arrives.

Syntax

  • C#
  • VB.NET
delegate void WebSocketConnectDelegate(object Sender, WebSocketConnectArgs Args);
The WebSocketConnectEvent(Args.Action,Args.User) syntax has these parts:
Args.ActionWebActions enumeration value. Determines if websocket is accepted.
Args.UserWebUser object. Reference to the user who is connected to the server.

Delegate Sub WebSocketConnectDelegate(ByVal Sender as Object, ByVal Args As WebSocketConnectArgs)
The WebSocketConnectEvent(Args.Action,Args.User) syntax has these parts:
Args.ActionWebActions enumeration value. Determines if websocket is accepted.
Args.UserWebUser object. Reference to the user who is connected to the server.

Remarks

This event is fired when user wants to upgrade regular HTTP connection to websocket, so it can perform full-duplex communication with the server. You can decide to Accept or Deny the connection. By default, all websocket requests will be denied.

Before accepting you should perform "security" check if you want to trust incoming connection, since it may basically send you any kind of information for which you should decide to accept it or not. Typically, you should check Request Headers to see if they match for what you expect them to be.
You can also use URI to differentiate different websocket requests - based on how you plan to handle them in the code.

Once connection is accepted, when data starts arriving you will get notified using WebSocketDataEvent event.

Platforms

Windows