RemovePeer() private method

private RemovePeer ( NetEndPoint ep ) : void
ep NetEndPoint
return void
Exemplo n.º 1
0
        private void RemovePeer(NetEndPoint endPoint)
        {
            _peers.Remove(endPoint);
#if WINRT && !UNITY_EDITOR
            _socket.RemovePeer(endPoint);
#endif
        }
Exemplo n.º 2
0
        //Update function
        private void UpdateLogic()
        {
#if DEBUG
            if (SimulateLatency)
            {
                var time = DateTime.UtcNow;
                lock (_pingSimulationList)
                {
                    for (int i = 0; i < _pingSimulationList.Count; i++)
                    {
                        var incomingData = _pingSimulationList[i];
                        if (incomingData.TimeWhenGet <= time)
                        {
                            DataReceived(incomingData.Data, incomingData.Data.Length, incomingData.EndPoint);
                            _pingSimulationList.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
#endif

            //Process acks
            lock (_peers)
            {
                int delta = _logicThread.SleepTime;
                foreach (NetPeer netPeer in _peers.Values)
                {
                    if (netPeer.ConnectionState == ConnectionState.Connected && netPeer.TimeSinceLastPacket > DisconnectTimeout)
                    {
                        netPeer.DebugWrite("Disconnect by timeout: {0} > {1}", netPeer.TimeSinceLastPacket, DisconnectTimeout);
                        var netEvent = CreateEvent(NetEventType.Disconnect);
                        netEvent.Peer             = netPeer;
                        netEvent.DisconnectReason = DisconnectReason.Timeout;
                        EnqueueEvent(netEvent);

                        lock (_peersToRemove)
                        {
                            _peersToRemove.Enqueue(netPeer.EndPoint);
                        }
                    }
                    else if (netPeer.ConnectionState == ConnectionState.Disconnected)
                    {
                        var netEvent = CreateEvent(NetEventType.Disconnect);
                        netEvent.Peer             = netPeer;
                        netEvent.DisconnectReason = DisconnectReason.ConnectionFailed;
                        EnqueueEvent(netEvent);

                        lock (_peersToRemove)
                        {
                            _peersToRemove.Enqueue(netPeer.EndPoint);
                        }
                    }
                    else
                    {
                        netPeer.Update(delta);
                    }
                }
                lock (_peersToRemove)
                {
                    while (_peersToRemove.Count > 0)
                    {
                        var ep = _peersToRemove.Dequeue();
                        _peers.Remove(ep);
#if WINRT && !UNITY_EDITOR
                        _socket.RemovePeer(ep);
#endif
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected void SocketRemovePeer(NetEndPoint ep)
        {
#if WINRT && !UNITY_EDITOR
            _socket.RemovePeer(ep);
#endif
        }