``refactor(rpc): 优化RPC客户端管理逻辑,移除冗余clientidmap,整合blazing服务调用``
This commit is contained in:
@@ -138,45 +138,40 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
s.parser(c, msg.Payload)
|
||||
})
|
||||
}
|
||||
if c.InboundBuffered() > 0 {
|
||||
if err := c.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data
|
||||
logging.Errorf("failed to wake up the connection, %v", err)
|
||||
return gnet.Close
|
||||
}
|
||||
}
|
||||
|
||||
return gnet.None
|
||||
}
|
||||
|
||||
func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
|
||||
for {
|
||||
if s.discorse {
|
||||
handle(conn)
|
||||
if s.discorse {
|
||||
handle(conn)
|
||||
}
|
||||
data, err := s.codec.Decode(conn)
|
||||
if err != nil {
|
||||
if conn.Context().(*player.ClientData).ERROR_CONNUT > 5 {
|
||||
action = gnet.Close
|
||||
}
|
||||
data, err := s.codec.Decode(conn)
|
||||
if err != nil {
|
||||
if conn.Context().(*player.ClientData).ERROR_CONNUT > 5 {
|
||||
action = gnet.Close
|
||||
}
|
||||
conn.Context().(*player.ClientData).ERROR_CONNUT += 1
|
||||
break
|
||||
}
|
||||
|
||||
//client := conn.RemoteAddr().String()
|
||||
_ = s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
s.parser(conn, data)
|
||||
})
|
||||
conn.Context().(*player.ClientData).ERROR_CONNUT += 1
|
||||
|
||||
}
|
||||
|
||||
//client := conn.RemoteAddr().String()
|
||||
_ = s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
s.parser(conn, data)
|
||||
})
|
||||
|
||||
if conn.InboundBuffered() > 0 {
|
||||
|
||||
t, _ := conn.Peek(conn.InboundBuffered())
|
||||
fmt.Println("剩余数据", conn.InboundBuffered(), string(t))
|
||||
if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data
|
||||
logging.Errorf("failed to wake up the connection, %v", err)
|
||||
return gnet.Close
|
||||
}
|
||||
}
|
||||
|
||||
return gnet.None
|
||||
return action
|
||||
|
||||
}
|
||||
|
||||
@@ -202,7 +197,7 @@ func handle(c gnet.Conn) {
|
||||
// 读取数据并检查是否为跨域请求
|
||||
data, err := c.Peek(len(TEXT))
|
||||
if err != nil {
|
||||
//log.Printf("Error reading cross-domain request: %v", err)
|
||||
log.Printf("Error reading cross-domain request: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user