Repository navigation
✨ 新增 WebSocket Client 通信协议 - #4
Merged
Merged
Conversation
新增通用传输层定位的 WebSocket 客户端,复用统一的 IProtocol 生命周期与 IProtocolManager 实例管理: - IWebSocketProtocol / IWebSocketCommunicationConfig:文本/二进制收发、 Closed/Reconnected 事件、自定义请求头与 SubProtocol、ws/wss 校验 - WebSocketProtocolClient:后台接收循环(分片合并、大小限制)、并发发送 串行化、心跳保活与应答超时、异常断线自动重连、优雅关闭;Closed 事件以 原子摘除连接为唯一发布点,保证每个连接恰好发布一次 - ClientWebSocketConnection 适配层集中承载 TFM 差异:net9+ 原生 Ping/Pong 应答超时、net8 TCP Keep-Alive 探测、net481 ArraySegment 路径 - 实例键 = 规范化 EndpointUrl(仅 scheme/host/默认端口)+ SubProtocol + ConnectionIdentity,敏感请求头不入键;不同认证身份不复用连接 - 单元测试 33 个,基于 TcpListener 的本地测试服务器,不依赖公网与第三方组件 - 更新发展路线、docs 协议页面与示例,版本号 1.1.0 -> 1.2.0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request 描述
提交前检查
变更类型
相关 Issue
无
目的
问题描述:
新增定位为通用传输层的 WebSocket Client 协议,复用统一的
IProtocol生命周期与IProtocolManager实例管理,为 MES 网关等场景提供基础通信能力(消息序列化约定、请求-响应匹配、Topic 订阅、Token 刷新等应用层能力由调用方实现):IWebSocketProtocol/IWebSocketCommunicationConfig:文本/二进制消息收发、MessageReceived/Closed/Reconnected事件、自定义请求头(Bearer Token 等认证头)与 SubProtocol、仅接受ws:///wss://WebSocketProtocolClient(基于 BCLClientWebSocket,无第三方依赖):后台接收循环(分片合并、超限以 MessageTooBig 关闭)、并发发送串行化、心跳保活与应答超时、异常断线自动重连、优雅关闭握手、幂等释放Closed事件以"原子摘除连接"为唯一发布点,保证每个连接恰好发布一次(含对端不确认关闭帧的超时场景)EndpointUrl(仅 scheme/host/默认端口,path/query 保留语义)+SubProtocol+ConnectionIdentity;敏感请求头不入键,不同认证身份不会复用连接ClientWebSocketConnection适配层集中承载目标框架差异:net9+原生 Ping/Pong 应答超时、net8TCP Keep-Alive 探测、net481ArraySegment 兼容路径TcpListener+WebSocket.CreateFromStream的本地测试服务器,不依赖公网与第三方组件预期影响:
CommProtocol增加WebSocket枚举值;ProtocolManager.CreateProtocol与GetInstanceKey增加对应分支评估
性能影响:
兼容性问题:
ICommunicationConfig未改动(Ip字段保留但不参与 WebSocket 连接与实例键),对现有调用方完全向后兼容net481通过适配层使用ArraySegment重载,公共二进制接口统一为byte[];KeepAliveTimeout在net481无法在传输层按连接强制,文档已说明替代方案额外信息
图片/截图
无 UI 更改
Copyright (c) MAS(厦门威光) Corporation. All rights reserved.
🤖 Generated with Claude Code