①简单点的:
httpsv.AddWebSocketService<Chat> ("/ChatWithNyan", () => new Chat (" Nyan!"));
②高级点的:
wssv.AddWebSocketService<Chat> (
"/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);
}
return true; // If valid.
}
}
);
要想问红字这一堆,用平时的C#转vb代码工具,转不了的。还是说这种是C#独有的语法糖,vb已经被抛弃,不被微软照顾这种写法?
此主题相关图片如下:微信截图_20201221101436.png

[此贴子已经被作者于2020/12/21 10:18:20编辑过]