Пример #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (tcp != null)
                    {
                        tcp.Dispose();
                    }

                    if (udp != null)
                    {
                        udp.Dispose();
                    }

                    if (receivedData != null)
                    {
                        receivedData.Dispose();
                    }
                }

                disposed = true;
            }
        }
Пример #2
0
        public override void Dispose()
        {
            foreach (var connection in _connectionManager.GetAllConnections())
            {
                DisconnectConnectionAsync(connection).Wait();
            }

            if (_handler != null)
            {
                _handler.ConnectionEvent -= OnConnectionEvent;
                _handler.MessageEvent    -= OnMessageEventAsync;
                _handler.ErrorEvent      -= OnErrorEvent;
                _handler.ServerEvent     -= OnServerEvent;
                _handler.Dispose();
            }
            base.Dispose();
        }