[Modify] Replace it

This commit is contained in:
sta 2022-01-29 21:34:25 +09:00
parent 468119790c
commit d6ce637000

View File

@ -120,33 +120,39 @@ namespace Example3
/* /*
httpsv.AddWebSocketService<Chat> ( httpsv.AddWebSocketService<Chat> (
"/Chat", "/Chat",
() => s => {
new Chat ("Anon#") { s.Prefix = "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", s.Protocol = "chat";
// To ignore the Sec-WebSocket-Extensions header. // To ignore the Sec-WebSocket-Extensions header.
IgnoreExtensions = true, s.IgnoreExtensions = true;
// To emit a WebSocket.OnMessage event when receives a ping. // To emit a WebSocket.OnMessage event when receives a ping.
EmitOnPing = true, s.EmitOnPing = true;
// To validate the Origin header. // To validate the Origin header.
OriginValidator = val => { s.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.
Uri origin; Uri origin;
return !val.IsNullOrEmpty () return !val.IsNullOrEmpty ()
&& Uri.TryCreate (val, UriKind.Absolute, out origin) && Uri.TryCreate (val, UriKind.Absolute, out origin)
&& origin.Host == "localhost"; && origin.Host == "localhost";
}, };
// To validate the cookies. // To validate the cookies.
CookiesValidator = (req, res) => { s.CookiesValidator = (req, res) => {
// Check the cookies in 'req', and set the cookies to send to // Check the cookies in 'req', and set the cookies to send to
// the client with 'res' if necessary. // the client with 'res' if necessary.
foreach (Cookie cookie in req) { foreach (var cookie in req) {
cookie.Expired = true; cookie.Expired = true;
res.Add (cookie); res.Add (cookie);
} }
return true; // If valid. return true; // If valid.
} };
} }
); );
*/ */