1
This commit is contained in:
parent
d52d3829bb
commit
73263a3ebd
@ -148,7 +148,6 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
|
||||
{
|
||||
await SendCustomMessageAsync(ctx, address, 0, 4, 0);//发送版本信息请求
|
||||
}
|
||||
UpdateConnectionContext(address, ctx);
|
||||
await UpdateCommunicationStateCountAsync(address, ctx);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -158,23 +157,20 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateConnectionContext(byte address, IChannelHandlerContext ctx)
|
||||
|
||||
|
||||
private async Task UpdateCommunicationStateCountAsync(byte address, IChannelHandlerContext ctx)
|
||||
{
|
||||
if (!_connections.ContainsKey(address))
|
||||
{
|
||||
await SendInitMsgToDeviceAsync(ctx, address);
|
||||
_connections.TryAdd(address, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
_connections[address] =ctx;
|
||||
}
|
||||
|
||||
private async Task UpdateCommunicationStateCountAsync(byte address, IChannelHandlerContext ctx)
|
||||
{
|
||||
if (_connections.TryGetValue(address, out _))
|
||||
{
|
||||
//_communicationStateCounts[address]++;
|
||||
//已经存在的装置地址
|
||||
}
|
||||
else
|
||||
{
|
||||
//新加入的装置的地址
|
||||
await SendInitMsgToDeviceAsync(ctx, address);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendInitMsgToDeviceAsync(IChannelHandlerContext ctx, byte address)
|
||||
|
Loading…
x
Reference in New Issue
Block a user