|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
wssv.Log.Level = LogLevel.TRACE;
|
|
|
|
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
|
|
|
|
/* HTTP Authentication (Basic/Digest)
|
|
|
|
/*
|
|
|
|
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
|
|
|
|
wssv.AuthenticationSchemes = AuthenticationSchemes.Digest;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|