diff --git a/Example/Example.pidb b/Example/Example.pidb index e7223650..ef4dd4ef 100644 Binary files a/Example/Example.pidb and b/Example/Example.pidb differ diff --git a/Example2/Example2.pidb b/Example2/Example2.pidb index be8d641a..e5a67cb5 100644 Binary files a/Example2/Example2.pidb and b/Example2/Example2.pidb differ diff --git a/README.md b/README.md index bb3bd0ba..c2732295 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,32 @@ ### WebSocket client ### +```cs +using System; +using WebSocketSharp; + +namespace Example { + + public class Program { + + public static void Main(string[] args) + { + using (var ws = new WebSocket("ws://dragonsnest.far/Laputa")) + { + ws.OnMessage += (sender, e) => + { + Console.WriteLine("Laputa says: {0}", e.Data); + }; + + ws.Connect(); + ws.Send("BALUS"); + Console.ReadKey(true); + } + } + } +} +``` + #### Step 1 #### Required namespace. @@ -21,7 +47,7 @@ The `WebSocket` class exists in the `WebSocketSharp` namespace. Creating a instance of the `WebSocket` class. ```cs -using (WebSocket ws = new WebSocket("ws://example.com")) +using (var ws = new WebSocket("ws://example.com")) { ... } @@ -140,6 +166,37 @@ In addition, the `Close()` and `Close(code)` methods exist. ### WebSocket server ### +```cs +using System; +using WebSocketSharp; +using WebSocketSharp.Server; + +namespace Example { + + public class Laputa : WebSocketService + { + protected override void OnMessage(MessageEventArgs e) + { + var msg = e.Data.Equals("balus", StringComparison.InvariantCultureIgnoreCase) + ? "I've been balused already..." + : "I'm not available now."; + Send(msg); + } + } + + public class Program { + + public static void Main(string[] args) + { + var wssv = new WebSocketServiceHost("ws://dragonsnest.far/Laputa"); + wssv.Start(); + Console.ReadKey(true); + wssv.Stop(); + } + } +} +``` + #### Step 1 #### Required namespace. diff --git a/websocket-sharp.userprefs b/websocket-sharp.userprefs index 9b182064..a518f3ad 100644 --- a/websocket-sharp.userprefs +++ b/websocket-sharp.userprefs @@ -1,6 +1,10 @@  - + + + + + diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 5c36af83..5a6ccf18 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ