Modified a few for Example2
This commit is contained in:
parent
fce7f3bc6a
commit
0f22268f9a
@ -36,11 +36,11 @@ namespace Example2
|
|||||||
/* 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 = identity => {
|
wssv.UserCredentialsFinder = id => {
|
||||||
var expected = "nobita";
|
var expected = "nobita";
|
||||||
return identity.Name == expected
|
return id.Name == expected
|
||||||
? new NetworkCredential (expected, "password", "gunfighter")
|
? new NetworkCredential (expected, "password", "gunfighter")
|
||||||
: null;
|
: null; // If the user credentials aren't found.
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -60,27 +60,30 @@ namespace Example2
|
|||||||
() => new Chat ("Anon#") {
|
() => new Chat ("Anon#") {
|
||||||
Protocol = "chat",
|
Protocol = "chat",
|
||||||
// To validate the Origin header.
|
// To validate the Origin header.
|
||||||
OriginValidator = value => {
|
OriginValidator = val => {
|
||||||
|
// Check the value of the Origin header, and return true if valid.
|
||||||
Uri origin;
|
Uri origin;
|
||||||
return !value.IsNullOrEmpty () &&
|
return !val.IsNullOrEmpty () &&
|
||||||
Uri.TryCreate (value, 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) => {
|
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) {
|
foreach (Cookie cookie in req) {
|
||||||
cookie.Expired = true;
|
cookie.Expired = true;
|
||||||
res.Add (cookie);
|
res.Add (cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true; // If valid.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wssv.Start ();
|
wssv.Start ();
|
||||||
if (wssv.IsListening) {
|
if (wssv.IsListening) {
|
||||||
Console.WriteLine ("Listening on port {0}, providing services:", wssv.Port);
|
Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", wssv.Port);
|
||||||
foreach (var path in wssv.WebSocketServices.Paths)
|
foreach (var path in wssv.WebSocketServices.Paths)
|
||||||
Console.WriteLine ("- {0}", path);
|
Console.WriteLine ("- {0}", path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user