Example #1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (_server.PeersCount > 0)
            {
                Logger.Trace("Connected Clients: {0}/{1}/{2}", _server.GetPeersCount(ConnectionState.Connected), _server.PeersCount, _connectedPeers.Count);
            }

            foreach (var kvp in _connectedPeers.ToList())
            {
                var peer = kvp.Value;
                if (peer.ConnectionState != ConnectionState.Connected)
                {
                    VoiceClientDisconnected?.Invoke(kvp.Key);
                    _connectedPeers.TryRemove(kvp.Key, out var unused);
                    continue;
                }

                if (peer.PacketsCountInReliableOrderedQueue > _maxOutQueueSize)
                {
                    Logger.Debug($"{peer.EndPoint} {peer.Ping} => {peer.PacketsCountInReliableOrderedQueue} queuesize exceeded disconnecting");
                    VoiceClientDisconnected?.Invoke(peer.ConnectId);
                    _connectedPeers.TryRemove(peer.ConnectId, out var unused);
                    _server.DisconnectPeerForce(peer);
                }
            }
        }
Example #2
0
 public void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo)
 {
     if (_connectedPeers.TryRemove(peer.ConnectId, out var unused))
     {
         _server.DisconnectPeerForce(peer);
         Thread.Sleep(200);
         Logger.Debug("Client disconnected: {0} : {1}", peer.EndPoint, disconnectInfo.Reason);
         try
         {
             VoiceClientDisconnected?.Invoke(peer.ConnectId);
         }
         catch (Exception ex)
         {
             Logger.Warn(ex);
         }
     }
 }