func onCliPacket(peerConn *zzcommon.PeerConn_t) (ret int) { gLock.Lock() defer gLock.Unlock() fmt.Println("onCliPacket") peerConn.ParseProtoHead() ret = onRecv(peerConn) return ret }
//获取消息的长度,0表示消息还未接受完成, //ERROR_DISCONNECT_PEER表示长度有误,服务端断开 func onSerGetPacketLen(peerConn *zzcommon.PeerConn_t, packetLength int) (ret int) { if (uint32)(packetLength) < zzcommon.ProtoHeadLength { //长度不足一个包头中的长度大小 return 0 } peerConn.ParseProtoHead() if (uint32)(peerConn.RecvProtoHead.PacketLength) < zzcommon.ProtoHeadLength { return zzcommon.ERROR_DISCONNECT_PEER } fmt.Print(peerConn.RecvProtoHead) if gTcpServer.PacketLengthMax <= (uint32)(peerConn.RecvProtoHead.PacketLength) { return zzcommon.ERROR_DISCONNECT_PEER } if packetLength < int(peerConn.RecvProtoHead.PacketLength) { return 0 } fmt.Println(peerConn) return int(peerConn.RecvProtoHead.PacketLength) }