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)
上一篇 2025年6月21日 下午1:22
下一篇 2025年6月21日 下午2:01


相关推荐

  • 阿里云发布手机“一键养虾”产品JVS Claw

    阿里云发布手机“一键养虾”产品JVS Claw

    2026年3月14日
    2
  • 淘宝核心系统团队博客在哪_团队理念

    淘宝核心系统团队博客在哪_团队理念http://rdc.taobao.com/blog/cs/?paged=2这是 淘宝核心系统团队的博客,核心系统团队的总目标是为淘宝和阿里集团打造一个高性能、高可扩展、低碳、低成本、稳定可靠的软件基础设施平台。目前的主要工作领域如下图所示:

    2022年8月13日
    7
  • 二叉树后序遍历的非递归实现_二叉树的后序遍历非递归详细

    二叉树后序遍历的非递归实现_二叉树的后序遍历非递归详细一、递归实现前序,序,后序遍历;对于二叉树,前面已经采用递归的方式实现的其前序,中序,后序遍历,具体请参见:http://blog.csdn.net/dai_wen/article/details/78955411那么,如何采用非递归的方式遍历树呢?下面,以实现中序遍历二叉树为主题展开:二、非递归实现中序遍历:1,结构:首先,对于中序遍历,我们知道,原则是先走到的结点后访问,后走到的结点

    2025年11月16日
    4
  • 基于Vue和Node.js的电商后台管理系统

    基于Vue和Node.js的电商后台管理系统电商后台管理系统(前端项目)预览后端API接口源码下载.接口API功能用于管理用户账号,商品分类,商品信息,订单,数据统计等业务功能开发模式电商后台管理系统整体采用前后端分离的开发模式,其中前端项目是基于Vue技术栈的SPA项目技术选型前端项目技术栈VueVue-routerElement-UIAxiosEcharts后端项目技术栈Node.jsExpressJwtMysqlSequelize接口API.后端源码下载

    2022年6月4日
    49
  • EM算法(Expectation Maximization Algorithm)详解

    EM算法(Expectation Maximization Algorithm)详解EM算法(ExpectationMaximizationAlgorithm)详解主要内容EM算法简介预备知识极大似然估计Jensen不等式EM算法详解问题描述EM算法推导EM算法流程EM算法优缺点以及应用1、EM算法简介  EM算法是一种迭代优化策略,由于它的计算方法中每一次迭代都分两步,其中一个为期望步(E步),另一个为极大步(M步),所以算法被称…

    2022年6月24日
    33
  • IDEA下maven分模块开发,web块不能创建serlvet的问题的解决方案

    IDEA下maven分模块开发,web块不能创建serlvet的问题的解决方案

    2021年8月23日
    82

发表回复

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

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