flocked翻译_physicked翻译

flocked翻译_physicked翻译FleckisaWebSocketserverimplementationinC#.BranchedfromtheNuggetproject,Fleckrequiresnoinheritance,container,oradditionalreferences.ExampleThefollowingisanexamplethatwillecho…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

Fleck is a WebSocket server implementation in C#. Branched from the Nugget project, Fleck requires no inheritance, container, or additional references.

Example

The following is an example that will echo to a client.

var server = new WebSocketServer(“ws://0.0.0.0:8181”);

server.Start(socket =>

{

socket.OnOpen = () => Console.WriteLine(“Open!”);

socket.OnClose = () => Console.WriteLine(“Close!”);

socket.OnMessage = message => socket.Send(message);

});

Supported WebSocket Versions

Fleck supports several WebSocket versions of modern web browsers

Hixie-Draft-76/Hybi-00 (Safari 5, Chrome < 14, Firefox 4 (when enabled))

Hybi-07 (Firefox 6)

Hybi-10 (Chrome 14-16, Firefox 7)

Hybi-13 (Chrome 17+)

Secure WebSockets (wss://)

Enabling secure connections requires two things: using the scheme wss instead of ws, and pointing Fleck to an x509 certificate containing a public and private key

var server = new WebSocketServer(“wss://0.0.0.0:8431”);

server.Certificate = new X509Certificate2(“MyCert.pfx”);

server.Start(socket =>

{

//…use as normal

});

SubProtocol Negotiation

To enable negotiation of subprotocols, specify the supported protocols on theWebSocketServer.SupportedSubProtocolsproperty. The negotiated subprotocol will be available on the socket’s ConnectionInfo.NegotiatedSubProtocol.

If no supported subprotocols are found on the client request (the Sec-WebSocket-Protocol header), the connection will be closed.

var server = new WebSocketServer(“ws://0.0.0.0:8181”);

server.SupportedSubProtocols = new []{ “superchat”, “chat” };

server.Start(socket =>

{

//socket.ConnectionInfo.NegotiatedSubProtocol is populated

});

Custom Logging

Fleck can log into Log4Net or any other third party logging system. Just override the FleckLog.LogAction property with the desired behavior.

ILog logger = LogManager.GetLogger(typeof(FleckLog));

FleckLog.LogAction = (level, message, ex) => {

switch(level) {

case LogLevel.Debug:

logger.Debug(message, ex);

break;

case LogLevel.Error:

logger.Error(message, ex);

break;

case LogLevel.Warn:

logger.Warn(message, ex);

break;

default:

logger.Info(message, ex);

break;

}

};

Disable Nagle’s Algorithm

Set NoDelay to true on the WebSocketConnection.ListenerSocket

var server = new WebSocketServer(“ws://0.0.0.0:8181”);

server.ListenerSocket.NoDelay = true;

server.Start(socket =>

{

//Child connections will not use Nagle’s Algorithm

});

Auto Restart After Listen Error

Set RestartAfterListenError to true on the WebSocketConnection

var server = new WebSocketServer(“ws://0.0.0.0:8181”);

server.RestartAfterListenError = true;

server.Start(socket =>

{

//…use as normal

});

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227252.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • illenium什么水平_尼采读本

    illenium什么水平_尼采读本写在最前面:目前自动化测试并不属于新鲜的事物,或者说自动化测试的各种方法论已经层出不穷,但是,能够在项目中持之以恒的实践自动化测试的团队,却依旧不是非常多。有的团队知道怎么做,做的还不够好;有的团队还正在探索和摸索怎么做,甚至还有一些多方面的技术上和非技术上的旧系统需要重构……本文将会从使用和实践两个视角,尝试对基于WebUI自动化测试做细致的分析和解读,给各位去思考和实践做一点引路…

    2022年9月6日
    3
  • TCP和UDP的特点_TCP和UDP位于

    TCP和UDP的特点_TCP和UDP位于原文链接:https://www.jianshu.com/p/ef1811b3b44eOSI参考模型和TCP/IP协议群1.TCP/IP协议群的具体含义从字面意义上讲,有人可能会认为TCP/IP是指TCP和IP两种协议.实际生活中有时也确实就是指这两种协议.然而在很多情况下,它只是利用IP进行通信时所必须用到的协议群的统称.具体来说,IP或ICMP,TCP或U…

    2022年9月20日
    0
  • JS检查是否支持Storage

    查看效果:http://hovertree.com/code/html5/q69kvsi6.htm代码:<!DOCTYPEhtml><html><head&gt

    2021年12月22日
    42
  • 字符串数组转换为list集合

    字符串数组转换为list集合String[]arr={“a”,”C”,”abc”}; //asList该方法可以直接将一个数组转换为list集合,但是该集合是[只读的],不能对得到的集合进行增删改List<String>asList=Arrays.asList(arr);System.out.println(asList);//结果:[a,C,abc]Listlis…

    2022年6月21日
    27
  • XGBoost:参数解释

    XGBoost:参数解释XGBoost参数在运行XGboost之前,必须设置三种类型成熟:generalparameters,boosterparameters和taskparameters:Generalparameters:参数控制在提升(boosting)过程中使用哪种booster,常用的booster有树模型(tree)和线性模型(linearmodel)。Boosterparameters:这取

    2022年5月27日
    43
  • 2021微信小程序反编译(小程序反编译工具)

    该网站是小程序反编译社区,永久免费开放下载所有反编译的小程序https://unpack.marchccc.top/

    2022年4月12日
    332

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号