This commit is contained in:
@@ -72,7 +72,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
|
||||
|
||||
//logging.Infof("conn[%v] disconnected", c.RemoteAddr().String())
|
||||
v, _ := c.Context().(*player.ClientData)
|
||||
v.LF.Close() //关闭继续接受
|
||||
|
||||
if v.Player != nil {
|
||||
v.Player.Save() //保存玩家数据
|
||||
|
||||
@@ -161,13 +161,9 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
return
|
||||
}
|
||||
|
||||
t := c.Context().(*player.ClientData)
|
||||
for _, msg := range messages {
|
||||
|
||||
if t.LF.Running() {
|
||||
t.LF.Producer().Write(msg.Payload)
|
||||
}
|
||||
|
||||
s.onevent(c, msg.Payload)
|
||||
//t.OnEvent(msg.Payload)
|
||||
}
|
||||
|
||||
@@ -189,13 +185,7 @@ func (s *Server) handleTCP(conn gnet.Conn) (action gnet.Action) {
|
||||
return gnet.Close
|
||||
|
||||
}
|
||||
|
||||
if t, ok := conn.Context().(*player.ClientData); ok {
|
||||
if t.LF.Running() {
|
||||
t.LF.Producer().Write(data)
|
||||
}
|
||||
|
||||
}
|
||||
s.onevent(conn, data)
|
||||
|
||||
if conn.InboundBuffered() > 0 {
|
||||
if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data
|
||||
@@ -233,3 +223,12 @@ func handle(c gnet.Conn) {
|
||||
|
||||
//return
|
||||
}
|
||||
|
||||
func (s *Server) onevent(c gnet.Conn, data []byte) {
|
||||
if t, ok := c.Context().(*player.ClientData); ok {
|
||||
s.workerPool.Submit(func() { //提交任务
|
||||
t.OnEvent(data)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user