From e35babea1b934395e70475b9ff271f6b72c9ce9c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jul 2016 15:12:43 +0900 Subject: [PATCH] [Modify] Edit it --- README.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2936189e..e6314f0d 100644 --- a/README.md +++ b/README.md @@ -567,25 +567,27 @@ And if you would like to validate the **Origin** header, **Cookies**, or both in ```csharp wssv.AddWebSocketService ( "/Chat", - () => new Chat () { - 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 == "example.com"; - }, - 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) { - cookie.Expired = true; - res.Add (cookie); - } + () => + new Chat () { + 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 == "example.com"; + }, + 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) { + cookie.Expired = true; + res.Add (cookie); + } - return true; // If valid. + return true; // If valid. + } } - }); +); ``` And also if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketBehavior.Context.Origin` and `WebSocketBehavior.Context.CookieCollection` properties.