[Modify] Polish it
This commit is contained in:
parent
2c1e2dfc62
commit
e707edabd1
@ -13,8 +13,9 @@ namespace Example2
|
|||||||
{
|
{
|
||||||
// Create a new instance of the WebSocketServer class.
|
// Create a new instance of the WebSocketServer class.
|
||||||
//
|
//
|
||||||
// If you would like to provide the secure connection, you should create a new instance with
|
// If you would like to provide the secure connection, you should
|
||||||
// the 'secure' parameter set to true, or a wss scheme WebSocket URL.
|
// create a new instance with the 'secure' parameter set to true,
|
||||||
|
// or a wss scheme WebSocket URL.
|
||||||
|
|
||||||
var wssv = new WebSocketServer (4649);
|
var wssv = new WebSocketServer (4649);
|
||||||
//var wssv = new WebSocketServer (5963, true);
|
//var wssv = new WebSocketServer (5963, true);
|
||||||
@ -54,17 +55,16 @@ namespace Example2
|
|||||||
|
|
||||||
// Not to remove the inactive sessions periodically.
|
// Not to remove the inactive sessions periodically.
|
||||||
//wssv.KeepClean = false;
|
//wssv.KeepClean = false;
|
||||||
|
|
||||||
// To resolve to wait for socket in TIME_WAIT state.
|
|
||||||
//wssv.ReuseAddress = true;
|
|
||||||
#endif
|
#endif
|
||||||
/* To provide the secure connection.
|
// To provide the secure connection.
|
||||||
|
/*
|
||||||
var cert = ConfigurationManager.AppSettings["ServerCertFile"];
|
var cert = ConfigurationManager.AppSettings["ServerCertFile"];
|
||||||
var passwd = ConfigurationManager.AppSettings["CertFilePassword"];
|
var passwd = ConfigurationManager.AppSettings["CertFilePassword"];
|
||||||
wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd);
|
wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* To provide the HTTP Authentication (Basic/Digest).
|
// To provide the HTTP Authentication (Basic/Digest).
|
||||||
|
/*
|
||||||
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
|
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
|
||||||
wssv.Realm = "WebSocket Test";
|
wssv.Realm = "WebSocket Test";
|
||||||
wssv.UserCredentialsFinder = id => {
|
wssv.UserCredentialsFinder = id => {
|
||||||
@ -77,21 +77,25 @@ namespace Example2
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// To resolve to wait for socket in TIME_WAIT state.
|
||||||
|
//wssv.ReuseAddress = true;
|
||||||
|
|
||||||
// Add the WebSocket services.
|
// Add the WebSocket services.
|
||||||
wssv.AddWebSocketService<Echo> ("/Echo");
|
wssv.AddWebSocketService<Echo> ("/Echo");
|
||||||
wssv.AddWebSocketService<Chat> ("/Chat");
|
wssv.AddWebSocketService<Chat> ("/Chat");
|
||||||
|
|
||||||
/* Add the WebSocket service with initializing.
|
// Add the WebSocket service with initializing.
|
||||||
|
/*
|
||||||
wssv.AddWebSocketService<Chat> (
|
wssv.AddWebSocketService<Chat> (
|
||||||
"/Chat",
|
"/Chat",
|
||||||
() =>
|
() =>
|
||||||
new Chat ("Anon#") {
|
new Chat ("Anon#") {
|
||||||
// To send the Sec-WebSocket-Protocol header that has a subprotocol name.
|
// To send the Sec-WebSocket-Protocol header that has a subprotocol name.
|
||||||
Protocol = "chat",
|
Protocol = "chat",
|
||||||
// To emit a WebSocket.OnMessage event when receives a ping.
|
|
||||||
EmitOnPing = true,
|
|
||||||
// To ignore the Sec-WebSocket-Extensions header.
|
// To ignore the Sec-WebSocket-Extensions header.
|
||||||
IgnoreExtensions = true,
|
IgnoreExtensions = true,
|
||||||
|
// To emit a WebSocket.OnMessage event when receives a ping.
|
||||||
|
EmitOnPing = true,
|
||||||
// To validate the Origin header.
|
// To validate the Origin header.
|
||||||
OriginValidator = val => {
|
OriginValidator = val => {
|
||||||
// Check the value of the Origin header, and return true if valid.
|
// Check the value of the Origin header, and return true if valid.
|
||||||
|
Loading…
Reference in New Issue
Block a user