mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:32:26 +08:00
完善机器人
This commit is contained in:
@@ -150,6 +150,7 @@ func (k *KcpConnectManager) acceptHandle(listener *kcp.Listener) {
|
||||
}
|
||||
conn.SetACKNoDelay(true)
|
||||
conn.SetWriteDelay(false)
|
||||
conn.SetWindowSize(255, 255)
|
||||
atomic.AddInt32(&CLIENT_CONN_NUM, 1)
|
||||
logger.Info("client connect, convId: %v", convId)
|
||||
kcpRawSendChan := make(chan *ProtoMsg, 1000)
|
||||
|
||||
@@ -94,7 +94,13 @@ func EncodePayloadToBin(kcpMsg *KcpMsg, xorKey []byte) (bin []byte) {
|
||||
if kcpMsg.ProtoData == nil {
|
||||
kcpMsg.ProtoData = make([]byte, 0)
|
||||
}
|
||||
bin = make([]byte, len(kcpMsg.HeadData)+len(kcpMsg.ProtoData)+12)
|
||||
// 检查长度
|
||||
packetLen := len(kcpMsg.HeadData) + len(kcpMsg.ProtoData) + 12
|
||||
if packetLen > PacketMaxLen {
|
||||
logger.Error("packet len too long")
|
||||
return make([]byte, 0)
|
||||
}
|
||||
bin = make([]byte, packetLen)
|
||||
// 头部幻数
|
||||
bin[0] = 0x45
|
||||
bin[1] = 0x67
|
||||
|
||||
Reference in New Issue
Block a user