Ejemplo n.º 1
0
        /// <summary>
        ///     Sends a packet to all super peers looking after a zone and waits for their replies.
        /// </summary>
        /// <param name="zone">Zone to send packet to.</param>
        /// <param name="packet">Packet to send.</param>
        private void SendPacketToZoneSuperPeersWaitForReply(Zone zone, SuperPeerPacket packet)
        {
            foreach (ZoneSuperPeer peer in zone.SuperPeers)
            {
                if (!RegisteredToZoneSuperPeer(peer))
                {
                    continue;
                }

                foreach (ClientToSuperPeerConnection c in m_superPeerConnections)
                {
                    if (c.Connection.Connected == true &&
                        c.Connection.ConnectionEstablished == true && 
                        c.Connection.IPAddress == peer.ClientIPAddress &&
                        c.Connection.Port == peer.ClientListenPort)
                    {
                        packet.SuperPeerID = peer.ID;
                        c.Connection.SendPacketAndWaitAsync(packet).Wait();
                    }
                }
            }
        }
        /// <summary>
        ///     Processes an incoming packet from the arbitrator that relates to this client.
        /// </summary>
        /// <param name="packet">Packet to process.</param>
        public void RecievedArbitratorPacket(SuperPeerPacket packet)
        {
            // Has arbitrator finished retrieving our account.
            if (packet is SuperPeerRetrieveAccountReplyPacket)
            {
                if (IsActive == true)
                {
                    SuperPeerRetrieveAccountReplyPacket specificPacket = packet as SuperPeerRetrieveAccountReplyPacket;
                    FinishRegister(specificPacket.Account);
                }
            }

            // Has arbitrator finished storing our account.
            else if (packet is SuperPeerStoreAccountReplyPacket)
            {
                if (IsActive == true)
                {
                    SuperPeerStoreAccountReplyPacket specificPacket = packet as SuperPeerStoreAccountReplyPacket;
                    FinishUnregister();
                }
            }
        }
        /// <summary>
        ///     Processes an incoming packet from the client to the super peer.
        /// </summary>
        /// <param name="packet">Packet to process.</param>
        public void RecievedPacket(SuperPeerPacket packet)
        {
            // Peer is giving us an update of their movement speed.
            if (packet is SuperPeerSetMovementVectorPacket)
            {
                SuperPeerSetMovementVectorPacket specificPacket = packet as SuperPeerSetMovementVectorPacket;

                m_movementVectorX       = specificPacket.VectorX;
                m_movementVectorY       = specificPacket.VectorY;
                m_movementVectorSpeed   = specificPacket.Speed;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Invoked when an arbitrator sends a packet to this super peer.
 /// </summary>
 public void ArbitratorRecievedPacket(Connection connection, SuperPeerPacket packet)
 {
 }