mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化]优化目录
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"pandax/iothub/netbase"
|
||||
exhook2 "pandax/iothub/server/emqxserver/protobuf"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/global_model"
|
||||
"pandax/pkg/global/model"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
"time"
|
||||
)
|
||||
@@ -81,7 +81,7 @@ func (s *HookGrpcService) OnClientConnack(ctx context.Context, in *exhook2.Clien
|
||||
func (s *HookGrpcService) OnClientConnected(ctx context.Context, in *exhook2.ClientConnectedRequest) (*exhook2.EmptySuccess, error) {
|
||||
global.Log.Info(fmt.Sprintf("Client %s Connected ", in.Clientinfo.GetNode()))
|
||||
token := netbase.GetUserName(in.Clientinfo)
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
err := etoken.GetDeviceToken(token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -96,7 +96,7 @@ func (s *HookGrpcService) OnClientConnected(ctx context.Context, in *exhook2.Cli
|
||||
func (s *HookGrpcService) OnClientDisconnected(ctx context.Context, in *exhook2.ClientDisconnectedRequest) (*exhook2.EmptySuccess, error) {
|
||||
global.Log.Info(fmt.Sprintf("%s断开连接", in.Clientinfo.Username))
|
||||
token := netbase.GetUserName(in.Clientinfo)
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
err := etoken.GetDeviceToken(token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -180,7 +180,7 @@ func (s *HookGrpcService) OnMessagePublish(ctx context.Context, in *exhook2.Mess
|
||||
res.Value = &exhook2.ValuedResponse_BoolResult{BoolResult: true}
|
||||
return res, nil
|
||||
}
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
etoken.GetDeviceToken(in.Message.Headers["username"])
|
||||
// 获取topic类型
|
||||
ts := time.Now().Format("2006-01-02 15:04:05.000")
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"pandax/iothub/hook_message_work"
|
||||
"pandax/iothub/netbase"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/global_model"
|
||||
"pandax/pkg/global/model"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -42,7 +42,7 @@ func InitHttpHook(addr string, hs *hook_message_work.HookService) {
|
||||
case http.StateHijacked, http.StateClosed:
|
||||
etoken, _ := activeConnections.Load(conn.RemoteAddr().String())
|
||||
if etoken != nil {
|
||||
data := netbase.CreateConnectionInfo(message.DisConnectMes, "http", conn.RemoteAddr().String(), conn.RemoteAddr().String(), etoken.(*global_model.DeviceAuth))
|
||||
data := netbase.CreateConnectionInfo(message.DisConnectMes, "http", conn.RemoteAddr().String(), conn.RemoteAddr().String(), etoken.(*model.DeviceAuth))
|
||||
activeConnections.Delete(conn.RemoteAddr().String())
|
||||
service.HookService.MessageCh <- data
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func (hhs *HookHttpService) hook(req *restful.Request, resp *restful.Response) {
|
||||
resp.Write([]byte("解析上报参数失败"))
|
||||
return
|
||||
}
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
etoken.GetDeviceToken(token)
|
||||
_, ok := activeConnections.Load(req.Request.RemoteAddr)
|
||||
// 是否需要添加设备上线通知
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"pandax/iothub/hook_message_work"
|
||||
"pandax/iothub/netbase"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/global_model"
|
||||
"pandax/pkg/global/model"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
"time"
|
||||
)
|
||||
@@ -48,7 +48,7 @@ func InitTcpHook(addr string, hs *hook_message_work.HookService) {
|
||||
|
||||
func (hhs *HookTcpService) hook() {
|
||||
isAuth := false
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
for {
|
||||
buf := make([]byte, 128)
|
||||
n := 0
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"pandax/iothub/hook_message_work"
|
||||
"pandax/iothub/netbase"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/global_model"
|
||||
"pandax/pkg/global/model"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
"time"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ func InitUdpHook(addr string, hs *hook_message_work.HookService) {
|
||||
}
|
||||
buffer := make([]byte, 1024)
|
||||
authMap := make(map[string]bool)
|
||||
etoken := &global_model.DeviceAuth{}
|
||||
etoken := &model.DeviceAuth{}
|
||||
hhs := &HookUdpService{
|
||||
HookService: hs,
|
||||
conn: server.listener,
|
||||
|
||||
Reference in New Issue
Block a user