diff --git a/Example/Program.cs b/Example/Program.cs index f3d91f6d..78c8fef0 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -15,56 +15,63 @@ namespace Example // use the using statement. And the WebSocket connection will be closed with // close status 1001 (going away) when the control leaves the using block. // - // If you would like to connect to the server with the secure connection, - // you should create the instance with the wss scheme WebSocket URL. + // If you would like to connect to a server with the secure connection, + // you should create a new instance with a wss scheme WebSocket URL. using (var nf = new Notifier ()) using (var ws = new WebSocket ("ws://echo.websocket.org")) //using (var ws = new WebSocket ("wss://echo.websocket.org")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) + //using (var ws = new WebSocket ("wss://localhost:5963/Echo")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo?name=nobita")) - //using (var ws = new WebSocket ("wss://localhost:4649/Echo")) + //using (var ws = new WebSocket ("wss://localhost:5963/Echo?name=nobita")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat")) + //using (var ws = new WebSocket ("wss://localhost:5963/Chat")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) - //using (var ws = new WebSocket ("wss://localhost:4649/Chat")) + //using (var ws = new WebSocket ("wss://localhost:5963/Chat?name=nobita")) { // Set the WebSocket events. ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); ws.OnMessage += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Message", - Body = !e.IsPing ? e.Data : "Received a ping.", - Icon = "notification-message-im" - }); + nf.Notify ( + new NotificationMessage { + Summary = "WebSocket Message", + Body = !e.IsPing ? e.Data : "Received a ping.", + Icon = "notification-message-im" + } + ); ws.OnError += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Error", - Body = e.Message, - Icon = "notification-message-im" - }); + nf.Notify ( + new NotificationMessage { + Summary = "WebSocket Error", + Body = e.Message, + Icon = "notification-message-im" + } + ); ws.OnClose += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = String.Format ("WebSocket Close ({0})", e.Code), - Body = e.Reason, - Icon = "notification-message-im" - }); - + nf.Notify ( + new NotificationMessage { + Summary = String.Format ("WebSocket Close ({0})", e.Code), + Body = e.Reason, + Icon = "notification-message-im" + } + ); #if DEBUG // To change the logging level. ws.Log.Level = LogLevel.Trace; // To change the wait time for the response to the Ping or Close. - ws.WaitTime = TimeSpan.FromSeconds (10); + //ws.WaitTime = TimeSpan.FromSeconds (10); // To emit a WebSocket.OnMessage event when receives a ping. - ws.EmitOnPing = true; + //ws.EmitOnPing = true; + + // To enable the redirection. + //ws.EnableRedirection = true; #endif // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; @@ -76,7 +83,9 @@ namespace Example String.Format ( "Certificate:\n- Issuer: {0}\n- Subject: {1}", certificate.Issuer, - certificate.Subject)); + certificate.Subject + ) + ); return true; // If the server certificate is valid. }; @@ -88,16 +97,13 @@ namespace Example // To send the Origin header. //ws.Origin = "http://localhost:4649"; - // To send the Cookies. + // To send the cookies. //ws.SetCookie (new Cookie ("name", "nobita")); //ws.SetCookie (new Cookie ("roles", "\"idiot, gunfighter\"")); // To connect through the HTTP Proxy server. //ws.SetProxy ("http://localhost:3128", "nobita", "password"); - // To enable the redirection. - //ws.EnableRedirection = true; - // Connect to the server. ws.Connect ();