TsgcWSConnection

TsgcWSConnection is a wrapper of client WebSocket connections, you can access to this object on Server or Client Events.

 

Methods

  WriteData: sends a message to the client.

 

  Close: sends a close message to other peer. A "CloseCode" can be specified optionally. By default, the value sent is NORMAL close code. If you send a Negative Close code, the reason of closing won't be sent.

 

  Disconnect: close client connection from the server side. A "CloseCode" can be specified optionally.

 

  Ping: sends a ping to the client.

 

  AddTCPEndOfFrame: if connection is plain TCP, allows to set which byte/s define the end of message. Message is buffered till is received completely.

 

  Subscribed: returns if the connection is subscribed to a custom channel.

 

  Subscribe: subscribe this connection to a channel. Later you can Broadcast a message from server component to all connections subscribed to this channel.

 

  UnSubscribe: unsubscribe this from connection from a channel.

 

 

Properties

  Protocol: returns sub-protocol used on this connection.

 

  IP: returns Peer IP Address.

 

  Port: returns Peer Port.

 

  LocalIP: returns Host IP Address.

 

  LocalPort: returns Host Port.

 

  URL: returns URL requested by the client.

 

  Guid: returns connection ID.

 

  HeadersRequest: returns a list of Headers received on Request.

 

  HeadersResponse: returns a list of Headers sent as Response.

 

  RecBytes: number of bytes received.

 

  SendBytes: number of bytes sent.

 

  Transport: returns the transport type of connection:

 

trpRFC6455: a normal WebSocket connection.

 

trpHixie76: a WebSocket connection using draft WebSocket spec.

 

trpFlash: a WebSocket connection using Flash as FallBack.

 

trpSSE: a Server-Sent Events connection.

 

trpTCP: plain TCP connection.

 

 

TCPEndOfFrameScanBuffer: allows to define which method use to find end of message (if using trpTCP as tansport).

 

eofScanNone: every time a new packet arrive, OnBinary event is called.

 

eofScanLatestBytes: if latest bytes are equal to bytes added with AddTCPEndOfFrame method, OnBinary message is called, otherwise this packet is buffered

 

eofScanAllBytes: search in all packet if find bytes equal to bytes added with AddTCPEndOfFrame method. If true, OnBinary message is called, otherwise this packet is buffered

 

  Data: user session data object, here you can pass an object and access this every time you need, for example: you can pass a connection to a database, user session properties...