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

});

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • python读取图片信息_糖炒栗子大的好还是小的好

    python读取图片信息_糖炒栗子大的好还是小的好这是一篇最基础的爬虫实例,大佬就不要看了,比较适合零基础或者有少量基础同学阅读

  • leetcode归并排序_每次把待排序的区间划分为左右

    leetcode归并排序_每次把待排序的区间划分为左右以数组 intervals 表示若干个区间的集合,其中单个区间为 intervals[i] = [starti, endi] 。请你合并所有重叠的区间,并返回一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间。示例 1:输入:intervals = [[1,3],[2,6],[8,10],[15,18]]输出:[[1,6],[8,10],[15,18]]解释:区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6].示例 2:输入:intervals = [[1,4],[4,5

  • shell中的for循环用法详解

    shell中的for循环用法详解for命令:foriin的各种用法:foriin“file1”“file2”“file3”foriin/boot/*foriin/etc/*.confforiin$(seq-w10)–》等宽的01-10foriin{1..10}foriin$(ls)forIin$(

  • CSS的超链接样式设计

    CSS的超链接样式设计超链接是网页中最常用的对象,每个网页通过超链接相互联系在一起,从而构成一个完整的网站。而根据路径的不同,超链接可以分为以下三类:内部链接:内部链接所链接的目标一般位于同一个网站中,对于内部链接来说

  • Nhibernate 使用 (一)

    Nhibernate 使用 (一)一:介绍NHibernate是一个基于.Net的针对关系型数据库的对象持久化类库。Nhibernate来源于非常优秀的基于Java的Hibernate关系型持久化工具。NHibernate

  • k3s集群安装_hadoop跨集群配置

    k3s集群安装_hadoop跨集群配置文章目录一、k3s离线部署准备工作1.准备节点2.安装Docker3.[k3s官网](https://github.com/k3s-io/k3s/releases/tag/v1.18.6%2Bk3s1)中下载部署文件。部署步骤1.导入镜像:2.修改文件权限:3.安装4.检查是否安装成功:5.卸载k3s问题解决:1.出现kubernetesclusterunreachable:2.出现Theconnectiontotheserverlocalhost:8080wasrefu

发表回复

您的电子邮箱地址不会被公开。

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