Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1053_CycleLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 76aa78aa
由
刘韬
编写于
2023-07-13 13:09:12 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
45ed6db8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
2 行删除
DeviceLibrary/theMachine/RemoteService.cs
DeviceLibrary/theMachine/RemoteService.cs
查看文件 @
76aa78a
...
...
@@ -16,10 +16,14 @@ namespace DeviceLibrary
/// </summary>
static
Dictionary
<
string
,
IWebSocketConnection
>
allClients
;
static
WebSocketServer
server
;
/// <summary>
/// 初始化监听服务
/// </summary>
public
static
void
Init
()
{
FleckLog
.
Level
=
LogLevel
.
Debug
;
allClients
=
new
Dictionary
<
string
,
IWebSocketConnection
>();
server
=
new
WebSocketServer
(
"ws://0.0.0.0:26901"
);
server
.
RestartAfterListenError
=
true
;
server
.
Start
(
client
=>
{
client
.
OnOpen
=
()
=>
...
...
@@ -46,7 +50,6 @@ namespace DeviceLibrary
client
.
OnMessage
=
message
=>
{
var
deviceGroupName
=
client
.
ConnectionInfo
.
Path
.
Substring
(
1
);
//SetINCall(deviceGroupName, JsonConvert.DeserializeObject<RemoteLoad>(message));
ProcessMessage
(
deviceGroupName
,
message
);
};
});
...
...
@@ -100,6 +103,11 @@ namespace DeviceLibrary
}
SendResult
(
deviceGroupName
,
isok
,
Seq
);
}
/// <summary>
/// 发送消息,不接收返回信息
/// </summary>
/// <param name="deviceGroupName">设备ID</param>
/// <param name="message"></param>
public
static
void
SendMessage
(
string
deviceGroupName
,
RemoteLoad
message
)
{
if
(!
allClients
.
ContainsKey
(
deviceGroupName
))
{
...
...
@@ -115,6 +123,13 @@ namespace DeviceLibrary
}
}
/// <summary>
/// 发送并等待返回
/// </summary>
/// <param name="GroupName">设备ID</param>
/// <param name="remoteLoad">载荷信息</param>
/// <param name="waittime">等待时间默认3000毫秒</param>
/// <returns></returns>
public
static
RemoteResult
SendAndWait
(
string
GroupName
,
RemoteLoad
remoteLoad
,
int
waittime
=
3000
)
{
remoteLoad
.
GroupName
=
GroupName
;
...
...
@@ -157,7 +172,7 @@ namespace DeviceLibrary
return
RemoteResult
.
Timeout
;
}
}
public
static
void
SendResult
(
string
deviceGroupName
,
bool
result
,
long
Seq
)
static
void
SendResult
(
string
deviceGroupName
,
bool
result
,
long
Seq
)
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Seq
=
Seq
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论