|
|
@ -46,28 +46,17 @@ namespace Example2 |
|
|
|
|
|
|
|
//var wssv = new WebSocketServer ("ws://[::1]:4649");
|
|
|
|
//var wssv = new WebSocketServer ("wss://[::1]:5963");
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
// To change the logging level.
|
|
|
|
wssv.Log.Level = LogLevel.Trace; |
|
|
|
|
|
|
|
// To change the wait time for the response to the WebSocket Ping or Close.
|
|
|
|
//wssv.WaitTime = TimeSpan.FromSeconds (2);
|
|
|
|
|
|
|
|
// To remove the inactive sessions periodically.
|
|
|
|
//wssv.KeepClean = true;
|
|
|
|
#endif
|
|
|
|
// To provide the secure connection.
|
|
|
|
/* |
|
|
|
var cert = ConfigurationManager.AppSettings["ServerCertFile"]; |
|
|
|
var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; |
|
|
|
wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd); |
|
|
|
*/ |
|
|
|
|
|
|
|
// To provide the HTTP Authentication (Basic/Digest).
|
|
|
|
/* |
|
|
|
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; |
|
|
|
wssv.Realm = "WebSocket Test"; |
|
|
|
wssv.UserCredentialsFinder = id => { |
|
|
|
wssv.UserCredentialsFinder = |
|
|
|
id => { |
|
|
|
var name = id.Name; |
|
|
|
|
|
|
|
// Return user name, password, and roles.
|
|
|
@ -77,9 +66,27 @@ namespace Example2 |
|
|
|
}; |
|
|
|
*/ |
|
|
|
|
|
|
|
// To remove the inactive sessions periodically.
|
|
|
|
//wssv.KeepClean = true;
|
|
|
|
|
|
|
|
// To resolve to wait for socket in TIME_WAIT state.
|
|
|
|
//wssv.ReuseAddress = true;
|
|
|
|
|
|
|
|
// To provide the secure connection.
|
|
|
|
/* |
|
|
|
var cert = ConfigurationManager.AppSettings["ServerCertFile"]; |
|
|
|
var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; |
|
|
|
|
|
|
|
wssv.SslConfiguration.ServerCertificate = new X509Certificate2 ( |
|
|
|
cert, |
|
|
|
passwd |
|
|
|
); |
|
|
|
*/ |
|
|
|
|
|
|
|
// To change the wait time for the response to the WebSocket Ping or Close.
|
|
|
|
//wssv.WaitTime = TimeSpan.FromSeconds (2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Add the WebSocket services.
|
|
|
|
wssv.AddWebSocketService<Echo> ("/Echo"); |
|
|
|
wssv.AddWebSocketService<Chat> ("/Chat"); |
|
|
|