Modified 'Query String, Origin header and Cookies'

This commit is contained in:
sta 2014-06-08 16:42:26 +09:00
parent 6e0ff2bd05
commit 3372de5b1a

View File

@ -518,7 +518,7 @@ wssv.AddWebSocketService<Chat> (
"/Chat", "/Chat",
() => new Chat () { () => new Chat () {
OriginValidator = value => { OriginValidator = value => {
// Check 'value' of the Origin header, and return true if it's valid // Check 'value' of the Origin header, and return true if valid
Uri origin; Uri origin;
return !value.IsNullOrEmpty () && return !value.IsNullOrEmpty () &&
Uri.TryCreate (value, UriKind.Absolute, out origin) && Uri.TryCreate (value, UriKind.Absolute, out origin) &&
@ -531,11 +531,13 @@ wssv.AddWebSocketService<Chat> (
res.Add (cookie); res.Add (cookie);
} }
return true; // If the Cookies are valid return true; // If valid
} }
}); });
``` ```
Also, if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketService.Context.Origin` and `WebSocketService.Context.CookieCollection` properties.
### Logging ### ### Logging ###
The `WebSocket` class includes the own logging function. The `WebSocket` class includes the own logging function.