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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 解决Execution failed for task ‘:app:checkDebugDuplicateClasses‘.

    解决Execution failed for task ‘:app:checkDebugDuplicateClasses‘.

    2021年10月2日
    54
  • Calendar类_java calendar

    Calendar类_java calendarCalendar类简介Calendar是javautil包下的一个工具类,提供了很方便的不同日期格式的处理。啥也不说了,直接撸代码:publicstaticvoidmain(String[]args){System.out.println(“————Calendar无参构造————“);//Cal…

    2022年9月24日
    2
  • android源码学习:ActivityManager类全理解

    android源码学习:ActivityManager类全理解android.app下有个ActivityManager类,给类的作用,官方的解释是:这个类提供有关、交互、activities,services和包含process的信息。这个类中的许多方法都是为了调试或信息的目的,它们不应该被用来影响应用程序的运行时行为,这些方法在方法级文档中被调用。大多数应用程序开发人员不应该使用这个类,大多数的方法都是专门用例的。然而,一些方法更广泛地适

    2022年5月16日
    53
  • 用Java实现文本编辑器

    用Java实现文本编辑器源码里有注释:importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjavax.swing.*;importjavax.swing.text.*;//简单的文本编辑器publicclassEditorextendsJFrame{ publicJTextPanetextPane=new…

    2022年6月3日
    36
  • 几乎所有互联网重要隐私都泄露了,想黑你还真的躲不掉

    几乎所有互联网重要隐私都泄露了,想黑你还真的躲不掉春节在家就是打麻将,不亦乐乎,赢了一点零花钱,无聊后,看手机,浏览StartupNews,看到《真想注销删除我的QQ号》这篇文章。作者因为看到了有人用泄露的QQ群(好多年前的)做出的关系图

    2022年7月3日
    28
  • 卡巴斯基升级_卡巴斯基免费版和收费版的区别

    卡巴斯基升级_卡巴斯基免费版和收费版的区别http://hi.baidu.com/sxcxq1128/blog/item/1918d0ef30523c232df534c1.html  卡巴斯基2010授权文件如何安装使用激活卡巴斯基2010版授权文件安装方法比以前的版本有些不同,请仔细看以下教程免得有了key也不会使用^_^第一步:打开卡巴斯基授权许可激活页点击左下角的“授权许可”上图

    2022年8月20日
    3

发表回复

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

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