This commit is contained in:
@@ -145,13 +145,10 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
t := c.Context().(*player.ClientData)
|
||||
//client := conn.RemoteAddr().String()
|
||||
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
for _, msg := range messages {
|
||||
t.LF.Producer().Write(msg.Payload)
|
||||
//t.OnEvent(msg.Payload)
|
||||
}
|
||||
})
|
||||
for _, msg := range messages {
|
||||
t.LF.Producer().Write(msg.Payload)
|
||||
//t.OnEvent(msg.Payload)
|
||||
}
|
||||
|
||||
return gnet.None
|
||||
}
|
||||
@@ -172,13 +169,9 @@ func (s *Server) handleTCP(conn gnet.Conn) (action gnet.Action) {
|
||||
|
||||
}
|
||||
|
||||
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
//conn.Context().(*player.ClientData).OnEvent(data)
|
||||
if t, ok := conn.Context().(*player.ClientData); ok {
|
||||
t.LF.Producer().Write(data)
|
||||
}
|
||||
|
||||
})
|
||||
if t, ok := conn.Context().(*player.ClientData); ok {
|
||||
t.LF.Producer().Write(data)
|
||||
}
|
||||
|
||||
if conn.InboundBuffered() > 0 {
|
||||
if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package socket
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/player"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -44,23 +42,27 @@ func (s *Server) QuitSelf(a int) error {
|
||||
s.quit = true
|
||||
if a != 0 {
|
||||
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
|
||||
value.KickMessage()
|
||||
if value != nil {
|
||||
value.Kick()
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
} else {
|
||||
go func() {
|
||||
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
|
||||
head := common.NewTomeeHeader(1001, value.Info.UserID)
|
||||
|
||||
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
|
||||
|
||||
value.SendPack(head.Pack(nil))
|
||||
if value != nil {
|
||||
value.KickMessage()
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
<-time.After(10 * time.Minute)
|
||||
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
|
||||
value.Kick()
|
||||
if value != nil {
|
||||
value.Kick()
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}()
|
||||
|
||||
@@ -191,6 +191,10 @@ func (h *ClientData) OnEvent(v []byte) {
|
||||
|
||||
}
|
||||
}()
|
||||
t, ok := h.Conn.Context().(*ClientData)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var header common.TomeeHeader
|
||||
// 解析Len(0-3字节)
|
||||
header.Len = binary.BigEndian.Uint32(v[0:4])
|
||||
@@ -209,11 +213,11 @@ func (h *ClientData) OnEvent(v []byte) {
|
||||
header.Data = []byte{} // 数据部分为空时显式初始化
|
||||
}
|
||||
if header.CMD > 1001 {
|
||||
if h.Conn.Context().(*ClientData).Player == nil {
|
||||
if t.Player == nil {
|
||||
fmt.Println(header.UserID, "账号未注册")
|
||||
return
|
||||
}
|
||||
if h.Conn.Context().(*ClientData).Player.Info == nil {
|
||||
if t.Player.Info == nil {
|
||||
fmt.Println(header.UserID, "未创建角色")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user