Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
若汝棋茗
RRQMSocket
提交
f6b1ecad
RRQMSocket
项目概览
若汝棋茗
/
RRQMSocket
大约 1 年 前同步成功
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
RRQMSocket
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f6b1ecad
编写于
4月 09, 2022
作者:
若
若汝棋茗
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复webSocket的连接问题
上级
ee8d4ea9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
15 addition
and
12 deletion
+15
-12
RRQMSocket.WebSocket/Client/WSClient.cs
RRQMSocket.WebSocket/Client/WSClient.cs
+2
-1
RRQMSocket.WebSocket/Common/WSTools.cs
RRQMSocket.WebSocket/Common/WSTools.cs
+8
-8
RRQMSocket.WebSocket/RRQMSocket.WebSocket.csproj
RRQMSocket.WebSocket/RRQMSocket.WebSocket.csproj
+5
-3
未找到文件。
RRQMSocket.WebSocket/Client/WSClient.cs
浏览文件 @
f6b1ecad
...
...
@@ -13,6 +13,7 @@
using
RRQMCore
;
using
RRQMCore.ByteManager
;
using
RRQMSocket.Http
;
using
RRQMSocket.WebSocket.Plugins
;
using
System.Text
;
using
System.Threading
;
...
...
@@ -78,7 +79,7 @@ namespace RRQMSocket.WebSocket
this
.
OnHandshaking
(
new
HttpContextEventArgs
(
request
));
var
response
=
this
.
Request
(
request
,
token
:
token
);
if
(
response
.
GetHeader
(
"
Sec-WebSocket-A
ccept"
)
!=
WSTools
.
CalculateBase64Key
(
base64Key
,
Encoding
.
UTF8
))
if
(
response
.
GetHeader
(
"
sec-websocket-a
ccept"
)
!=
WSTools
.
CalculateBase64Key
(
base64Key
,
Encoding
.
UTF8
))
{
this
.
MainSocket
.
Dispose
();
throw
new
RRQMException
(
"返回的应答码不正确。"
);
...
...
RRQMSocket.WebSocket/Common/WSTools.cs
浏览文件 @
f6b1ecad
...
...
@@ -61,10 +61,10 @@ namespace RRQMSocket.WebSocket
request
.
SetHeader
(
HttpHeaders
.
UserAgent
,
"RRQMSocket.WebSocket"
);
request
.
SetHeader
(
HttpHeaders
.
Upgrade
,
"websocket"
);
request
.
SetHeader
(
HttpHeaders
.
Origin
,
"RRQM"
);
request
.
SetHeader
(
"
Sec-WebSocket-V
ersion"
,
$"
{
version
}
"
);
request
.
SetHeader
(
"
sec-websocket-v
ersion"
,
$"
{
version
}
"
);
request
.
SetHeader
(
HttpHeaders
.
AcceptEncoding
,
"deflate, br"
);
base64Key
=
WSTools
.
CreateBase64Key
();
request
.
SetHeader
(
"
Sec-WebSocket-K
ey"
,
$"
{
base64Key
}
"
);
request
.
SetHeader
(
"
sec-websocket-k
ey"
,
$"
{
base64Key
}
"
);
return
request
;
}
...
...
@@ -88,19 +88,19 @@ namespace RRQMSocket.WebSocket
/// <returns></returns>
public
static
bool
TryGetResponse
(
HttpRequest
request
,
out
HttpResponse
response
)
{
string
upgrade
=
request
.
GetHeader
(
"Upgrade"
);
string
upgrade
=
request
.
GetHeader
(
HttpHeaders
.
Upgrade
);
if
(
string
.
IsNullOrEmpty
(
upgrade
))
{
response
=
null
;
return
false
;
}
string
connection
=
request
.
GetHeader
(
"Connection"
);
string
connection
=
request
.
GetHeader
(
HttpHeaders
.
Connection
);
if
(
string
.
IsNullOrEmpty
(
connection
))
{
response
=
null
;
return
false
;
}
string
secWebSocketKey
=
request
.
GetHeader
(
"
Sec-WebSocket-K
ey"
);
string
secWebSocketKey
=
request
.
GetHeader
(
"
sec-websocket-k
ey"
);
if
(
string
.
IsNullOrEmpty
(
secWebSocketKey
))
{
response
=
null
;
...
...
@@ -109,10 +109,10 @@ namespace RRQMSocket.WebSocket
response
=
new
HttpResponse
();
response
.
StatusCode
=
"101"
;
response
.
StatusMessage
=
"
Switching P
rotocols"
;
response
.
SetHeader
(
HttpHeaders
.
Connection
,
"
U
pgrade"
);
response
.
StatusMessage
=
"
switching p
rotocols"
;
response
.
SetHeader
(
HttpHeaders
.
Connection
,
"
u
pgrade"
);
response
.
SetHeader
(
HttpHeaders
.
Upgrade
,
"websocket"
);
response
.
SetHeader
(
"
Sec-WebSocket-A
ccept"
,
CalculateBase64Key
(
secWebSocketKey
,
request
.
Encoding
));
response
.
SetHeader
(
"
sec-websocket-a
ccept"
,
CalculateBase64Key
(
secWebSocketKey
,
request
.
Encoding
));
return
true
;
}
...
...
RRQMSocket.WebSocket/RRQMSocket.WebSocket.csproj
浏览文件 @
f6b1ecad
...
...
@@ -4,7 +4,7 @@
<ApplicationIcon>RRQM.ico</ApplicationIcon>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>RRQM.pfx</AssemblyOriginatorKeyFile>
<Version>8.0.
1
</Version>
<Version>8.0.
2
</Version>
<LangVersion>8.0</LangVersion>
<Company>若汝棋茗</Company>
<Copyright>Copyright © 2021 若汝棋茗</Copyright>
...
...
@@ -14,6 +14,7 @@
更新说明
修改:取消WSService,由插件WebSocketServerPlugin替代其功能。
新增:支持WSCommandLinePlugin,让快捷执行成为可能。
修复:ws连接问题。
API:https://www.yuque.com/eo2w71/rrqm
DEMO:https://gitee.com/RRQM_Home/RRQMBox</Description>
...
...
@@ -78,8 +79,9 @@ DEMO:https://gitee.com/RRQM_Home/RRQMBox</Description>
</ItemGroup>
<ItemGroup>
<PackageReference Include="RRQMSocket" Version="8.0.1" />
<PackageReference Include="RRQMSocket.Http" Version="8.0.1" />
<PackageReference Include="RRQMCore" Version="8.0.3" />
<PackageReference Include="RRQMSocket" Version="8.0.2" />
<PackageReference Include="RRQMSocket.Http" Version="8.0.2" />
</ItemGroup>
</Project>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录