Esempio n. 1
0
        void ProcessPacket(ClientProxy inClientProxy, NetIncomingMessage inInputStream)
        {
            //remember we got a packet so we know not to disconnect for a bit
            inClientProxy.UpdateLastPacketTime();

            uint32_t packetType;

            packetType = inInputStream.ReadUInt32();
            switch ((PacketType)packetType)
            {
            case PacketType.kHelloCC:
                //need to resend welcome. to be extra safe we should check the name is the one we expect from this address,
                //otherwise something weird is going on...
                SendWelcomePacket(inClientProxy);
                break;

            case PacketType.kInputCC:
                if (inClientProxy.GetDeliveryNotificationManager().ReadAndProcessState(inInputStream))
                {
                    HandleInputPacket(inClientProxy, inInputStream);
                }
                break;

            case PacketType.kRPC:
                HandleRPCPacket(inClientProxy, inInputStream);
                break;

            default:
                //LOG("Unknown packet type received from %s", inClientProxy.GetSocketAddress().ToString().c_str());
                break;
            }
        }
Esempio n. 2
0
        void SendStatePacketToClient(ClientProxy inClientProxy)
        {
            //build state packet
            var statePacket = GetServer().CreateMessage();

            //it's state!
            statePacket.Write((uint32_t)PacketType.kStateCC);

            InFlightPacket ifp = inClientProxy.GetDeliveryNotificationManager().WriteState(statePacket);

            WriteLastMoveTimestampIfDirty(statePacket, inClientProxy);

            AddScoreBoardStateToPacket(statePacket);

            var rmtd = new ReplicationManagerTransmissionData(inClientProxy.GetReplicationManagerServer());

            inClientProxy.GetReplicationManagerServer().Write(statePacket, rmtd);
            ifp.SetTransmissionData((int)TransmissionDataType.kReplicationManager, rmtd);

            var ret = GetServer().SendMessage(statePacket, inClientProxy.mConnection, NetDeliveryMethod.Unreliable);
            //log.InfoFormat("send {0}", ret);
        }