protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _socket.Dispose();
            }

            base.Dispose(disposing);
        }
Пример #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (Connected)
                {
                    CancelBackgroundReceiveLoop();
                    Disconnect();
                }

                _backgroundReceiveCTS.Dispose();
                _socket.Dispose();
            }
        }
Пример #3
0
        public void RemoveTarget(IAsyncSocket socket)
        {
            LightEvent e;
            _connectedClients.TryRemove(socket, out e);

            PlayerEndPoint endPoint;
            if (_playerEndPoints.TryRemove(socket.IpEndPoint, out endPoint))
            {
                BoDConsole.WriteLine($"Client: {socket.IpEndPoint.Address.MapToIPv4()}:{socket.IpEndPoint.Port} disconnected.");

                // If any PlayerEndPoint, other than the one that was just removed, 
                // references PlayerId, the player must be connected on another PlayerEndPoint.
                if (_playerEndPoints.Values.All(p => p.PlayerId != endPoint.PlayerId))
                {
                    Game game;
                    if (BoDService.PlayerIngame.TryRemove(endPoint.PlayerId, out game))
                    {
                        game.RemovePlayer(endPoint.PlayerId);
                    }
                }
            }
            socket.Dispose();
        }
Пример #4
0
 public void Dispose()
 {
     _stream?.Dispose();
     _socket?.Dispose();
 }