Refactored Example2
This commit is contained in:
parent
303709b043
commit
670af8919c
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
wssv.Log.Level = LogLevel.TRACE;
|
||||
#endif
|
||||
//var wssv = new WebSocketServer ("wss://localhost:4649"); // Secure
|
||||
|
||||
// HTTP Basic/Digest Authentication
|
||||
/*
|
||||
wssv.AuthenticationSchemes = AuthenticationSchemes.Digest;
|
||||
#if DEBUG
|
||||
wssv.Log.Level = LogLevel.TRACE;
|
||||
#endif
|
||||
|
||||
/* Secure Connection
|
||||
var cert = ConfigurationManager.AppSettings ["ServerCertFile"];
|
||||
var password = ConfigurationManager.AppSettings ["CertFilePassword"];
|
||||
wssv.Certificate = new X509Certificate2 (cert, password);
|
||||
*/
|
||||
|
||||
/* 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> ("/Echo");
|
||||
wssv.AddWebSocketService<Chat> ("/Chat");
|
||||
//wssv.AddWebSocketService<Chat> ("/Chat", () => new Chat ("Anon#"));
|
||||
//wssv.AddWebSocketService<Echo> ("/エコー");
|
||||
//wssv.AddWebSocketService<Chat> ("/チャット");
|
||||
|
||||
wssv.Start ();
|
||||
if (wssv.IsListening) {
|
||||
|
Loading…
Reference in New Issue
Block a user