mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化websocket
优化蓝图
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user