[Modify] Replace it

This commit is contained in:
sta 2022-01-24 22:14:17 +09:00
parent 21e8bed002
commit 421bf4b6b7

View File

@ -88,24 +88,30 @@ namespace Example2
/*
wssv.AddWebSocketService<Chat> (
"/Chat",
() =>
new Chat ("Anon#") {
s => {
s.Prefix = "Anon#";
// To send the Sec-WebSocket-Protocol header that has a subprotocol name.
Protocol = "chat",
s.Protocol = "chat";
// To ignore the Sec-WebSocket-Extensions header.
IgnoreExtensions = true,
s.IgnoreExtensions = true;
// To emit a WebSocket.OnMessage event when receives a ping.
EmitOnPing = true,
s.EmitOnPing = true;
// To validate the Origin header.
OriginValidator = val => {
s.OriginValidator = val => {
// Check the value of the Origin header, and return true if valid.
Uri origin;
return !val.IsNullOrEmpty ()
&& Uri.TryCreate (val, UriKind.Absolute, out origin)
&& origin.Host == "localhost";
},
};
// To validate the cookies.
CookiesValidator = (req, res) => {
s.CookiesValidator = (req, res) => {
// Check the cookies in 'req', and set the cookies to send to
// the client with 'res' if necessary.
foreach (Cookie cookie in req) {
@ -114,7 +120,7 @@ namespace Example2
}
return true; // If valid.
}
};
}
);
*/