[优化]设备数据上传并发处理,添加队列,以及并发数控制

This commit is contained in:
PandaX
2023-11-28 18:08:49 +08:00
parent 287c8a1b05
commit fd44f11c4b
4 changed files with 12 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ func (hhs *HookTcpService) hook() {
//设置断开连接
if isAuth {
data := netbase.CreateConnectionInfo(message.DisConnectMes, "tcp", hhs.conn.RemoteAddr().String(), hhs.conn.RemoteAddr().String(), etoken)
hhs.HookService.MessageCh <- data
hhs.HookService.Queue.Queue(data)
}
tcpclient.TcpClient.Delete(etoken.DeviceId)
isAuth = false
@@ -72,7 +72,7 @@ func (hhs *HookTcpService) hook() {
if auth {
global.Log.Infof("TCP协议 设备%s,认证成功", etoken.DeviceId)
data := netbase.CreateConnectionInfo(message.ConnectMes, "tcp", hhs.conn.RemoteAddr().String(), hhs.conn.RemoteAddr().String(), etoken)
hhs.HookService.MessageCh <- data
hhs.HookService.Queue.Queue(data)
isAuth = true
tcpclient.TcpClient.Store(etoken.DeviceId, hhs.conn)
hhs.Send("success")
@@ -92,7 +92,7 @@ func (hhs *HookTcpService) hook() {
data.Datas = fmt.Sprintf(`{"ts": "%s","rowdata": "%s"}`, ts, hexData)
// etoken中添加设备标识
hhs.HookService.MessageCh <- data
hhs.HookService.Queue.Queue(data)
}
}