Exemplo n.º 1
0
        internal void Teleport(TeleportState state)
        {
            IPAddress sendAddress = null;

            Debug.Assert(state != null);

            // Check to ensure the network is available.  If it isn't, teleport
            // to the local peer
//            if (oneTeleportAtATime == true && lastAsyncCall != null)
//            {
//                GameEngine.Current.ReceiveTeleportation(state, true);
//                CountLocalTeleportation();
//                return;
//            }

            // If there is more than one peer world, randomly pick
            // one to send the organism to
            if (PeerManager.KnownPeers.Count != 0)
            {
                // Pick a random peer
                sendAddress = _peerManager.GetRandomPeer();

                // If we pick ourselves, short circuit for perf (and so things don't get announced
                // on the screen as a valid teleport)
                if (sendAddress.Equals(_hostIP))
                {
                    sendAddress = null;
                }
            }

            if (sendAddress == null)
            {
                // Otherwise, teleport back to self
//                GameEngine.Current.ReceiveTeleportation(state, true);
//                CountLocalTeleportation();
                sendAddress = _hostIP;
//                return;
            }

            var workItem = new TeleportWorkItem(this, sendAddress.ToString(), state, PortNumber,
                                                NetworkTimeoutMsec, _peerConnectionLed);

            // Actually do the teleportation asynchronously so we don't block the UI
            TeleportDelegate teleport = workItem.DoTeleport;

            teleport.BeginInvoke(TeleportCallback, null);
        }
Exemplo n.º 2
0
        internal void Teleport(TeleportState state)
        {
            IPAddress sendAddress = null;
            Debug.Assert(state != null);

            // Check to ensure the network is available.  If it isn't, teleport
            // to the local peer
            //            if (oneTeleportAtATime == true && lastAsyncCall != null)
            //            {
            //                GameEngine.Current.ReceiveTeleportation(state, true);
            //                CountLocalTeleportation();
            //                return;
            //            }

            // If there is more than one peer world, randomly pick
            // one to send the organism to
            if (PeerManager.KnownPeers.Count != 0)
            {
                // Pick a random peer
                sendAddress = _peerManager.GetRandomPeer();

                // If we pick ourselves, short circuit for perf (and so things don't get announced
                // on the screen as a valid teleport)
                if (sendAddress.Equals(_hostIP))
                    sendAddress = null;
            }

            if (sendAddress == null)
            {
                // Otherwise, teleport back to self
            //                GameEngine.Current.ReceiveTeleportation(state, true);
            //                CountLocalTeleportation();
                sendAddress = _hostIP;
            //                return;
            }

            var workItem = new TeleportWorkItem(this, sendAddress.ToString(), state, PortNumber,
                                                NetworkTimeoutMsec, _peerConnectionLed);

            // Actually do the teleportation asynchronously so we don't block the UI
            TeleportDelegate teleport = workItem.DoTeleport;
            teleport.BeginInvoke(TeleportCallback, null);
        }