예제 #1
0
파일: main.go 프로젝트: 75912001/GoServer
func onCliPacket(peerConn *zzcommon.PeerConn_t) (ret int) {
	gLock.Lock()
	defer gLock.Unlock()

	fmt.Println("onCliPacket")
	peerConn.ParseProtoHead()

	ret = onRecv(peerConn)
	return ret
}
예제 #2
0
파일: main.go 프로젝트: 75912001/GoServer
func onCliGetPacketLen(peerConn *zzcommon.PeerConn_t, packetLength int) (ret int) {
	//fmt.Println("onCliGetPacketLen")
	if uint32(packetLength) < zzcommon.ProtoHeadLength { //长度不足一个包头中的长度大小
		return 0
	}
	peerConn.ParseProtoHeadPacketLength()
	if uint32(peerConn.RecvProtoHead.PacketLength) < zzcommon.ProtoHeadLength {
		return zzcommon.ERROR_DISCONNECT_PEER
	}
	if gTcpServer.PacketLengthMax <= uint32(peerConn.RecvProtoHead.PacketLength) {
		return zzcommon.ERROR_DISCONNECT_PEER
	}
	if packetLength < int(peerConn.RecvProtoHead.PacketLength) {
		return 0
	}
	fmt.Println("onCliGetPacketLen:", peerConn.RecvProtoHead.PacketLength)
	return int(peerConn.RecvProtoHead.PacketLength)
}
예제 #3
0
파일: main.go 프로젝트: 75912001/GoServer
//获取消息的长度,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)
}