Merge branch 'main' of github.com:72wo/blazing
This commit is contained in:
@@ -53,9 +53,10 @@ func (s *Server) OnClose(c gnet.Conn, _ error) (action gnet.Action) {
|
||||
}()
|
||||
atomic.AddInt64(&s.connected, -1)
|
||||
//logging.Infof("conn[%v] disconnected", c.RemoteAddr().String())
|
||||
v, ok := c.Context().(*player.ClientData)
|
||||
v, _ := c.Context().(*player.ClientData)
|
||||
v.Lf.Close() //关闭lockfree
|
||||
|
||||
if ok && v.Player != nil {
|
||||
if v.Player != nil {
|
||||
//cool.Loger.Info(context.TODO(), "准备保存", v.Player.Info.UserID)
|
||||
v.Player.Save() //保存玩家数据
|
||||
//cool.Loger.Info(context.TODO(), "保存完成", v.Player.Info.UserID)
|
||||
@@ -141,9 +142,15 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
for _, msg := range messages {
|
||||
t := c.Context().(*player.ClientData)
|
||||
//client := conn.RemoteAddr().String()
|
||||
_ = s.workerPool.Submit(func() {
|
||||
s.handler.Handle(c, msg.Payload)
|
||||
_ = s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
t.Lf.Producer().Write(&player.RecvData{
|
||||
|
||||
Conn: c,
|
||||
Data: msg.Payload,
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,11 +183,15 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
if data != nil {
|
||||
//client := conn.RemoteAddr().String()
|
||||
//cool.Loger.Debug(context.Background(), "数据", hex.EncodeToString(data))
|
||||
t := conn.Context().(*player.ClientData)
|
||||
|
||||
_ = s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
//todo 这里待实现注入player实体
|
||||
s.handler.Handle(conn, data)
|
||||
t.Lf.Producer().Write(&player.RecvData{
|
||||
|
||||
Conn: conn,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user