C# Class SocketIOClient.Client

Class to emulate socket.io javascript client capabilities for .net classes
Connection for wss or https urls
Inheritance: IDisposable, SocketIOClient.IClient
Afficher le fichier Open project: uken/UnitySocketIO-WebSocketSharp Class Usage Examples

Méthodes publiques

Свойство Type Description
ConnectionOpenEvent System.Threading.ManualResetEvent
LastErrorMessage string
MessageQueueEmptyEvent System.Threading.ManualResetEvent
MessageQueuePendingEvent System.Threading.ManualResetEvent

Protected Properties

Свойство Type Description
registrationManager RegistrationManager
uri Uri
wsClient WebSocket

Méthodes publiques

Méthode Description
Client ( string url ) : System
Close ( ) : void

Close SocketIO4Net.Client and clear all event registrations

Connect ( string endPoint ) : IEndPointClient
Connect ( ) : void

Initiate the connection with Socket.IO service

Dispose ( ) : void
Emit ( string eventName, Object payload ) : void

Asynchronously sends payload using eventName

payload must a string or Json Serializable

Mimicks Socket.IO client 'socket.emit('name',payload);' pattern

Do not use the reserved socket.io event names: connect, disconnect, open, close, error, retry, reconnect

Emit ( string eventName, Object payload, string endPoint, Action callback ) : void

Asynchronously sends payload using eventName

payload must a string or Json Serializable

Mimicks Socket.IO client 'socket.emit('name',payload);' pattern

Do not use the reserved socket.io event names: connect, disconnect, open, close, error, retry, reconnect

ArgumentOutOfRangeException will be thrown on reserved event names

On ( string eventName, Action action ) : void

Asynchronously calls the action delegate on event message notification

Mimicks the Socket.IO client 'socket.on('name',function(data){});' pattern

Reserved socket.io event names available: connect, disconnect, open, close, error, retry, reconnect

On ( string eventName, string endPoint, Action action ) : void
Send ( IMessage msg ) : void

Queue outbound message

Send ( string msg ) : void

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void
OnConnectionRetryAttemptEvent ( object sender, EventArgs e ) : void
OnErrorEvent ( object sender, ErrorEventArgs e ) : void
OnHeartBeatTimerCallback ( object state ) : void
OnMessageEvent ( IMessage msg ) : void

if a registerd event name is found, don't raise the more generic Message event

OnSocketConnectionClosedEvent ( object sender, EventArgs e ) : void
ReConnect ( ) : void
closeHeartBeatTimer ( ) : void
closeOutboundQueue ( ) : void
closeWebSocketClient ( ) : void
dequeuOutboundMessages ( ) : void

While connection is open, dequeue and send messages to the socket server

requestHandshake ( Uri uri, DownloadStringCompletedEventHandler handshakeCallback ) : void

Client performs an initial HTTP POST to obtain a SessionId (sid) assigned to a client, followed by the heartbeat timeout, connection closing timeout, and the list of supported transports.

The tansport and sid are required as part of the ws: transport connection

Private Methods

Méthode Description
EndAsyncEvent ( IAsyncResult result ) : void
HandshakeCallback ( object sender, DownloadStringCompletedEventArgs eventArgs ) : void
Send_backup ( string rawEncodedMessageText ) : void
wsClient_Closed ( object sender, WebSocketSharp e ) : void

websocket has closed unexpectedly - retry connection

wsClient_Error ( object sender, WebSocketSharp e ) : void
wsClient_MessageReceived ( object sender, WebSocketSharp e ) : void

Raw websocket messages from server - convert to message types and call subscribers of events and/or callbacks

wsClient_OpenEvent ( object sender, EventArgs e ) : void

Method Details

Client() public méthode

public Client ( string url ) : System
url string
Résultat System

Close() public méthode

Close SocketIO4Net.Client and clear all event registrations
public Close ( ) : void
Résultat void

Connect() public méthode

public Connect ( string endPoint ) : IEndPointClient
endPoint string
Résultat IEndPointClient

Connect() public méthode

Initiate the connection with Socket.IO service
public Connect ( ) : void
Résultat void

Dispose() public méthode

public Dispose ( ) : void
Résultat void

Dispose() protected méthode

protected Dispose ( bool disposing ) : void
disposing bool
Résultat void

Emit() public méthode

Asynchronously sends payload using eventName

payload must a string or Json Serializable

Mimicks Socket.IO client 'socket.emit('name',payload);' pattern

Do not use the reserved socket.io event names: connect, disconnect, open, close, error, retry, reconnect

public Emit ( string eventName, Object payload ) : void
eventName string
payload Object must be a string or a Json Serializable object
Résultat void

Emit() public méthode

Asynchronously sends payload using eventName

payload must a string or Json Serializable

Mimicks Socket.IO client 'socket.emit('name',payload);' pattern

Do not use the reserved socket.io event names: connect, disconnect, open, close, error, retry, reconnect

ArgumentOutOfRangeException will be thrown on reserved event names
public Emit ( string eventName, Object payload, string endPoint, Action callback ) : void
eventName string
payload Object must be a string or a Json Serializable object
endPoint string
callback Action
Résultat void

On() public méthode

Asynchronously calls the action delegate on event message notification

Mimicks the Socket.IO client 'socket.on('name',function(data){});' pattern

Reserved socket.io event names available: connect, disconnect, open, close, error, retry, reconnect

public On ( string eventName, Action action ) : void
eventName string
action Action
Résultat void

On() public méthode

public On ( string eventName, string endPoint, Action action ) : void
eventName string
endPoint string
action Action
Résultat void

OnConnectionRetryAttemptEvent() protected méthode

protected OnConnectionRetryAttemptEvent ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Résultat void

OnErrorEvent() protected méthode

protected OnErrorEvent ( object sender, ErrorEventArgs e ) : void
sender object
e ErrorEventArgs
Résultat void

OnHeartBeatTimerCallback() protected méthode

protected OnHeartBeatTimerCallback ( object state ) : void
state object
Résultat void

OnMessageEvent() protected méthode

if a registerd event name is found, don't raise the more generic Message event
protected OnMessageEvent ( IMessage msg ) : void
msg IMessage
Résultat void

OnSocketConnectionClosedEvent() protected méthode

protected OnSocketConnectionClosedEvent ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Résultat void

ReConnect() protected méthode

protected ReConnect ( ) : void
Résultat void

Send() public méthode

Queue outbound message
public Send ( IMessage msg ) : void
msg IMessage
Résultat void

Send() public méthode

public Send ( string msg ) : void
msg string
Résultat void

closeHeartBeatTimer() protected méthode

protected closeHeartBeatTimer ( ) : void
Résultat void

closeOutboundQueue() protected méthode

protected closeOutboundQueue ( ) : void
Résultat void

closeWebSocketClient() protected méthode

protected closeWebSocketClient ( ) : void
Résultat void

dequeuOutboundMessages() protected méthode

While connection is open, dequeue and send messages to the socket server
protected dequeuOutboundMessages ( ) : void
Résultat void

requestHandshake() protected méthode

Client performs an initial HTTP POST to obtain a SessionId (sid) assigned to a client, followed by the heartbeat timeout, connection closing timeout, and the list of supported transports.

The tansport and sid are required as part of the ws: transport connection

protected requestHandshake ( Uri uri, DownloadStringCompletedEventHandler handshakeCallback ) : void
uri Uri http://localhost:3000
handshakeCallback DownloadStringCompletedEventHandler
Résultat void

Property Details

ConnectionOpenEvent public_oe property

Connection Open Event
public ManualResetEvent,System.Threading ConnectionOpenEvent
Résultat System.Threading.ManualResetEvent

LastErrorMessage public_oe property

Value of the last error message text
public string LastErrorMessage
Résultat string

MessageQueueEmptyEvent public_oe property

ResetEvent for Outbound MessageQueue Empty Event - all pending messages have been sent
public ManualResetEvent,System.Threading MessageQueueEmptyEvent
Résultat System.Threading.ManualResetEvent

MessageQueuePendingEvent public_oe property

ResetEvent for Outbound MessageQueue Pending Messages Event - there are pending messages ready to send
public ManualResetEvent,System.Threading MessageQueuePendingEvent
Résultat System.Threading.ManualResetEvent

registrationManager protected_oe property

RegistrationManager for dynamic events
protected RegistrationManager registrationManager
Résultat RegistrationManager

uri protected_oe property

Uri of Websocket server
protected Uri uri
Résultat Uri

wsClient protected_oe property

Underlying WebSocket implementation
protected WebSocket wsClient
Résultat WebSocket