Refactored Example2
This commit is contained in:
parent
303709b043
commit
670af8919c
@ -11,16 +11,16 @@ namespace Example2
|
|||||||
{
|
{
|
||||||
var name = Context.QueryString ["name"];
|
var name = Context.QueryString ["name"];
|
||||||
var msg = name != null
|
var msg = name != null
|
||||||
? String.Format ("Returns '{0}' to {1}", e.Data, name)
|
? String.Format ("'{0}' to {1}", e.Data, name)
|
||||||
: e.Data;
|
: e.Data;
|
||||||
|
|
||||||
Send (msg);
|
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;
|
cookie.Expired = true;
|
||||||
response.Add (cookie);
|
response.Add (cookie);
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,22 @@ namespace Example2
|
|||||||
public static void Main (string [] args)
|
public static void Main (string [] args)
|
||||||
{
|
{
|
||||||
var wssv = new WebSocketServer (4649);
|
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 ("ws://localhost:4649");
|
||||||
//var wssv = new WebSocketServer ("wss://localhost:4649");
|
//var wssv = new WebSocketServer ("wss://localhost:4649"); // Secure
|
||||||
#if DEBUG
|
|
||||||
wssv.Log.Level = LogLevel.TRACE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// HTTP Basic/Digest Authentication
|
#if DEBUG
|
||||||
/*
|
wssv.Log.Level = LogLevel.TRACE;
|
||||||
wssv.AuthenticationSchemes = AuthenticationSchemes.Digest;
|
#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.Realm = "WebSocket Test";
|
||||||
wssv.UserCredentialsFinder = identity => {
|
wssv.UserCredentialsFinder = identity => {
|
||||||
var name = identity.Name;
|
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.KeepClean = false;
|
||||||
|
|
||||||
wssv.AddWebSocketService<Echo> ("/Echo");
|
wssv.AddWebSocketService<Echo> ("/Echo");
|
||||||
wssv.AddWebSocketService<Chat> ("/Chat");
|
wssv.AddWebSocketService<Chat> ("/Chat");
|
||||||
//wssv.AddWebSocketService<Chat> ("/Chat", () => new Chat ("Anon#"));
|
//wssv.AddWebSocketService<Chat> ("/Chat", () => new Chat ("Anon#"));
|
||||||
//wssv.AddWebSocketService<Echo> ("/エコー");
|
|
||||||
//wssv.AddWebSocketService<Chat> ("/チャット");
|
|
||||||
|
|
||||||
wssv.Start ();
|
wssv.Start ();
|
||||||
if (wssv.IsListening) {
|
if (wssv.IsListening) {
|
||||||
|
Loading…
Reference in New Issue
Block a user