Stop() public method

public Stop ( ) : void
return void
Beispiel #1
0
 /// <summary>
 /// Stop updating thread and listening
 /// </summary>
 public virtual void Stop()
 {
     if (IsRunning)
     {
         _logicThread.Stop();
         _socket.Close();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Force closes connection and stop all threads.
        /// </summary>
        public void Stop()
        {
            //Send disconnect packets
            lock (_peers)
                foreach (NetPeer netPeer in _peers.Values)
                {
                    var disconnectPacket = NetPacket.CreateRawPacket(PacketProperty.Disconnect, 8);
                    FastBitConverter.GetBytes(disconnectPacket, 1, netPeer.ConnectId);
                    SendRaw(disconnectPacket, netPeer.EndPoint);
                }

            //Clear
            ClearPeers();

            //Stop
            if (IsRunning)
            {
                _logicThread.Stop();
                _socket.Close();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Force closes connection and stop all threads.
        /// </summary>
        public void Stop()
        {
            //Send disconnect packets
            lock (_peers)
            {
                for (int i = 0; i < _peers.Count; i++)
                {
                    var disconnectPacket = _netPacketPool.Get(PacketProperty.Disconnect, 8);
                    FastBitConverter.GetBytes(disconnectPacket.RawData, 1, _peers[i].ConnectId);
                    SendRawAndRecycle(disconnectPacket, _peers[i].EndPoint);
                }
            }

            //Clear
            ClearPeers();

            //Stop
            if (IsRunning)
            {
                _logicThread.Stop();
                _socket.Close();
            }
        }