protected override void Dispose(bool disposing) { if (disposing) { _socket.Dispose(); } base.Dispose(disposing); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (Connected) { CancelBackgroundReceiveLoop(); Disconnect(); } _backgroundReceiveCTS.Dispose(); _socket.Dispose(); } }
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(); }
public void Dispose() { _stream?.Dispose(); _socket?.Dispose(); }