diff --git a/sysmodule/netmodule/wsmodule/WSModule.go b/sysmodule/netmodule/wsmodule/WSModule.go index 163b4ef..ba2dd43 100644 --- a/sysmodule/netmodule/wsmodule/WSModule.go +++ b/sysmodule/netmodule/wsmodule/WSModule.go @@ -119,7 +119,6 @@ func (ws *WSModule) recyclerReaderBytes([]byte) { func (ws *WSModule) NewWSClient(conn *network.WSConn) network.Agent { ws.mapClientLocker.Lock() defer ws.mapClientLocker.Unlock() - pClient := &WSClient{wsConn: conn, id: primitive.NewObjectID().Hex()} pClient.wsModule = ws ws.mapClient[pClient.id] = pClient @@ -159,6 +158,22 @@ func (ws *WSModule) GetProcessor() processor.IRawProcessor { return ws.process } +func (ws *WSModule) GetClientHeader(clientId string,key string) string { + ws.mapClientLocker.Lock() + defer ws.mapClientLocker.Unlock() + + pClient, ok := ws.mapClient[clientId] + if ok == false || pClient.wsConn == nil { + return "" + } + + if pClient.wsConn.GetHeader() == nil { + log.Warn("clientId header is nil", log.String("clientId", clientId)) + } + + return pClient.wsConn.GetHeader().Get(key) +} + func (ws *WSModule) GetClientIp(clientId string) string { ws.mapClientLocker.Lock() defer ws.mapClientLocker.Unlock() diff --git a/util/blueprint/graph.go b/util/blueprint/graph.go index 5f91e7a..9413e96 100644 --- a/util/blueprint/graph.go +++ b/util/blueprint/graph.go @@ -144,7 +144,7 @@ func (gc *graphConfig) GetNodeByID(nodeID string) *nodeConfig { func (gr *Graph) GetAndCreateReturnPort() IPort { p, ok := gr.globalVariables[ReturnVarial] - if ok { + if ok && p != nil { return p } @@ -168,6 +168,8 @@ func (gr *Graph) Do(entranceID int64, args ...any) (Port_Array, error) { if gr.globalVariables == nil { gr.globalVariables = map[string]IPort{} + }else { + gr.globalVariables[ReturnVarial] = nil } err := entranceNode.Do(gr, args...)