C# WebSocket WebSocket4Net Demo code

2598 단어 C#WebSocket
WebSocket4Net
a .NET websocket client implementation.
It originated from SuperWebSocket WebSocket Client. For better developing of the websocket client, it was separated from SuperWebSocket and was renamed to WebSocket4Net. WebSocket4Net will provide websocket client implementation for many different kinds of runtime:
.Net 2.0
.Net 3.5
.Net 4.0
Mono
Silverlight
WindowsPhone
Mono for Android
MonoTouch (New)
 
   
 
It is compatible with many websocket drafts:
Hybi-00
Hybi-10
RFC6455
 
NuGet Package: http://www.nuget.org/packages/WebSocket4Net
Demo code:  
 
using WebSocket4Net;
 
WebSocket websocket = new WebSocket("ws://localhost:2012/");
websocket.Opened += new EventHandler(websocket_Opened);
websocket.Error += new EventHandler(websocket_Error);
websocket.Closed += new EventHandler(websocket_Closed);
websocket.MessageReceived += new EventHandler(websocket_MessageReceived);
websocket.Open();

private void websocket_Opened(object sender, EventArgs e)
{
     websocket.Send("Hello World!");
}

좋은 웹페이지 즐겨찾기