Exemplo n.º 1
0
        public void Dispose()
        {
            if (m_timer != null)
            {
                lock (m_timer)
                {
                    Packet packet;
                    while (m_receiveQueue.Count > 0)
                    {
                        if (m_receiveQueue.TryDequeue(out packet))
                        {
                            packet.Delete();
                        }
                    }
                    m_timer.Dispose();
                    m_timer       = null;
                    m_timerAction = null;
                }
            }

            if (!m_peer.IsNull)
            {
                m_peer.Shutdown(300);
                m_peer.Delete();
            }
            GC.SuppressFinalize(this);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Stopping a running server and breaking all connections
 /// </summary>
 public void StopServer()
 {
     if (peer.IsActive())
     {
         peer.Shutdown();
         OnServerStop();
         IsRunning = false;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Disconnecting from the server
 /// </summary>
 public void Disconnect()
 {
     if (peer.IsActive())
     {
         IsConnecting = false;
         IsConnected  = false;
         peer.Shutdown();
         OnDisconnected(DisconnectReason.ByUser);
     }
 }