From 670af8919cb34837ddc7f7b44fc31ce2cc5e47d1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jan 2014 15:40:38 +0900 Subject: [PATCH] Refactored Example2 --- Example2/Echo.cs | 8 ++++---- Example2/Program.cs | 29 +++++++++++++---------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Example2/Echo.cs b/Example2/Echo.cs index 011ed2f4..c1cce786 100644 --- a/Example2/Echo.cs +++ b/Example2/Echo.cs @@ -11,16 +11,16 @@ namespace Example2 { var name = Context.QueryString ["name"]; var msg = name != null - ? String.Format ("Returns '{0}' to {1}", e.Data, name) + ? String.Format ("'{0}' to {1}", e.Data, name) : e.Data; Send (msg); } - protected override bool ValidateCookies (CookieCollection request, CookieCollection response) + protected override bool ValidateCookies ( + CookieCollection request, CookieCollection response) { - foreach (Cookie cookie in request) - { + foreach (Cookie cookie in request) { cookie.Expired = true; response.Add (cookie); } diff --git a/Example2/Program.cs b/Example2/Program.cs index bc3ba988..b45eeb56 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -12,16 +12,22 @@ namespace Example2 public static void Main (string [] args) { var wssv = new WebSocketServer (4649); - //var wssv = new WebSocketServer (4649, true); + //var wssv = new WebSocketServer (4649, true); // Secure //var wssv = new WebSocketServer ("ws://localhost:4649"); - //var wssv = new WebSocketServer ("wss://localhost:4649"); - #if DEBUG + //var wssv = new WebSocketServer ("wss://localhost:4649"); // Secure + +#if DEBUG wssv.Log.Level = LogLevel.TRACE; - #endif +#endif + + /* Secure Connection + var cert = ConfigurationManager.AppSettings ["ServerCertFile"]; + var password = ConfigurationManager.AppSettings ["CertFilePassword"]; + wssv.Certificate = new X509Certificate2 (cert, password); + */ - // HTTP Basic/Digest Authentication - /* - wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; + /* HTTP Authentication (Basic/Digest) + wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; wssv.Realm = "WebSocket Test"; wssv.UserCredentialsFinder = identity => { var name = identity.Name; @@ -31,20 +37,11 @@ namespace Example2 }; */ - // Secure Connection - /* - var cert = ConfigurationManager.AppSettings ["ServerCertFile"]; - var password = ConfigurationManager.AppSettings ["CertFilePassword"]; - wssv.Certificate = new X509Certificate2 (cert, password); - */ - //wssv.KeepClean = false; wssv.AddWebSocketService ("/Echo"); wssv.AddWebSocketService ("/Chat"); //wssv.AddWebSocketService ("/Chat", () => new Chat ("Anon#")); - //wssv.AddWebSocketService ("/エコー"); - //wssv.AddWebSocketService ("/チャット"); wssv.Start (); if (wssv.IsListening) {