Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
jxhczhl authored Aug 29, 2023
1 parent 1f3aac2 commit eb28de2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewClient(group string, name string, ws *websocket.Conn) *Clients {
return &Clients{
clientGroup: group,
clientName: name,
actionData: make(map[string]chan string), // action有消息后就保存到chan里
actionData: make(map[string]chan string, 1), // action有消息后就保存到chan里
clientWs: ws,
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func ws(c *gin.Context) {
action := msg[:strIndex]
client.actionData[action] <- msg[strIndex+5:]
logPrint("get_message:", msg[strIndex+5:])
hlSyncMap.Store(group+"->"+name, client)
//hlSyncMap.Store(group+"->"+name, client)
} else {
fmt.Println(msg, "message error")
}
Expand Down Expand Up @@ -147,6 +147,9 @@ func GQueryFunc(client *Clients, funcName string, param string, resChan chan<- s
}
res := <-client.actionData[funcName]
resChan <- res
defer func() {
close(resChan)
}()
}

func ResultSet(c *gin.Context) {
Expand Down Expand Up @@ -181,7 +184,7 @@ func ResultSet(c *gin.Context) {

c2 := make(chan string)
go GQueryFunc(client, Action, Param, c2)
go checkTimeout(c2)
//go checkTimeout(c2)
//把管道传过去,获得值就返回了
c.JSON(200, gin.H{"status": 200, "group": client.clientGroup, "name": client.clientName, "data": <-c2})

Expand Down Expand Up @@ -258,7 +261,6 @@ func TlsHandler() gin.HandlerFunc {
c.Next()
}
}

func main() {
for _, v := range os.Args {
if v == "log" {
Expand Down

0 comments on commit eb28de2

Please sign in to comment.