mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 12:03:50 +08:00
fix lock & http server error.
This commit is contained in:
parent
3709f5c7b9
commit
9f060ce2ed
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -157,7 +158,13 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
log.Infof("CQ HTTP 服务器已启动: %v", addr)
|
log.Infof("CQ HTTP 服务器已启动: %v", addr)
|
||||||
log.Fatal(s.engine.Run(addr))
|
err := s.engine.Run(addr)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
log.Infof("请检查端口是否被占用.")
|
||||||
|
time.Sleep(time.Second * 5)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,6 +314,8 @@ func (c *websocketConn) handleRequest(bot *coolq.CQBot, payload []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *websocketServer) onBotPushEvent(m coolq.MSG) {
|
func (s *websocketServer) onBotPushEvent(m coolq.MSG) {
|
||||||
|
s.eventConnMutex.Lock()
|
||||||
|
s.eventConnMutex.Unlock()
|
||||||
pos := 0
|
pos := 0
|
||||||
for _, conn := range s.eventConn {
|
for _, conn := range s.eventConn {
|
||||||
log.Debugf("向WS客户端 %v 推送Event: %v", conn.RemoteAddr().String(), m.ToJson())
|
log.Debugf("向WS客户端 %v 推送Event: %v", conn.RemoteAddr().String(), m.ToJson())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user