C# Класс SocketIOClient.Client

Class to emulate socket.io javascript client capabilities for .net classes
Connection for wss or https urls
Наследование: IDisposable, SocketIOClient.IClient
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ConnectionOpenEvent System.Threading.ManualResetEvent
LastErrorMessage string
MessageQueueEmptyEvent System.Threading.ManualResetEvent
MessageQueuePendingEvent System.Threading.ManualResetEvent

Защищенные свойства (Protected)

Свойство Тип Описание
registrationManager RegistrationManager
uri Uri
wsClient WebSocket

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

Client() публичный Метод

public Client ( string url ) : System
url string
Результат System

Close() публичный Метод

Close SocketIO4Net.Client and clear all event registrations
public Close ( ) : void
Результат void

Connect() публичный Метод

public Connect ( string endPoint ) : IEndPointClient
endPoint string
Результат IEndPointClient

Connect() публичный Метод

Initiate the connection with Socket.IO service
public Connect ( ) : void
Результат void

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

protected Dispose ( bool disposing ) : void
disposing bool
Результат void

Emit() публичный Метод

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
Результат void

Emit() публичный Метод

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
Результат void

On() публичный Метод

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
Результат void

On() публичный Метод

public On ( string eventName, string endPoint, Action action ) : void
eventName string
endPoint string
action Action
Результат void

OnConnectionRetryAttemptEvent() защищенный Метод

protected OnConnectionRetryAttemptEvent ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void

OnErrorEvent() защищенный Метод

protected OnErrorEvent ( object sender, ErrorEventArgs e ) : void
sender object
e ErrorEventArgs
Результат void

OnHeartBeatTimerCallback() защищенный Метод

protected OnHeartBeatTimerCallback ( object state ) : void
state object
Результат void

OnMessageEvent() защищенный Метод

if a registerd event name is found, don't raise the more generic Message event
protected OnMessageEvent ( IMessage msg ) : void
msg IMessage
Результат void

OnSocketConnectionClosedEvent() защищенный Метод

protected OnSocketConnectionClosedEvent ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void

ReConnect() защищенный Метод

protected ReConnect ( ) : void
Результат void

Send() публичный Метод

Queue outbound message
public Send ( IMessage msg ) : void
msg IMessage
Результат void

Send() публичный Метод

public Send ( string msg ) : void
msg string
Результат void

closeHeartBeatTimer() защищенный Метод

protected closeHeartBeatTimer ( ) : void
Результат void

closeOutboundQueue() защищенный Метод

protected closeOutboundQueue ( ) : void
Результат void

closeWebSocketClient() защищенный Метод

protected closeWebSocketClient ( ) : void
Результат void

dequeuOutboundMessages() защищенный Метод

While connection is open, dequeue and send messages to the socket server
protected dequeuOutboundMessages ( ) : void
Результат void

requestHandshake() защищенный Метод

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
Результат void

Описание свойств

ConnectionOpenEvent публичное свойство

Connection Open Event
public ManualResetEvent,System.Threading ConnectionOpenEvent
Результат System.Threading.ManualResetEvent

LastErrorMessage публичное свойство

Value of the last error message text
public string LastErrorMessage
Результат string

MessageQueueEmptyEvent публичное свойство

ResetEvent for Outbound MessageQueue Empty Event - all pending messages have been sent
public ManualResetEvent,System.Threading MessageQueueEmptyEvent
Результат System.Threading.ManualResetEvent

MessageQueuePendingEvent публичное свойство

ResetEvent for Outbound MessageQueue Pending Messages Event - there are pending messages ready to send
public ManualResetEvent,System.Threading MessageQueuePendingEvent
Результат System.Threading.ManualResetEvent

registrationManager защищенное свойство

RegistrationManager for dynamic events
protected RegistrationManager registrationManager
Результат RegistrationManager

uri защищенное свойство

Uri of Websocket server
protected Uri uri
Результат Uri

wsClient защищенное свойство

Underlying WebSocket implementation
protected WebSocket wsClient
Результат WebSocket