Exemplo n.º 1
0
        private void Terminate(Exception exception)
        {
            _stream.Close();
            _socket.Disconnect(false);
            _socket.Close();

            this.Connected = false;

            if (OnDisconnect != null)
            {
                OnDisconnect?.Invoke(this, exception.Message);
            }
            else
            {
                throw new PlayerIOError(ErrorCode.InternalError, string.Concat(new[] { "Connection from ", _endpoint.Address, " was closed. ", ", message: ", exception.Message }));
            }
        }
Exemplo n.º 2
0
        public void Disconnect()
        {
            if (Socket == null)
            {
                return;
            }

            try
            {
                Socket.Disconnect(false);
                Socket.Close();
                Socket = null;
            }
            catch (ObjectDisposedException) {}
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            OnDisconnect(this, null);
        }
Exemplo n.º 3
0
        public void Disconnect()
        {
            if (_socket == null)
            {
                return;
            }

            try
            {
                _socket.Disconnect(false);
                _socket.Close();
                _socket = null;
            }
            catch (ObjectDisposedException e) {}
            catch (Exception e)
            {
                Log.Warn("Error occurred while disconnecting from socket", e);
            }

            OnDisconnect(this, null);
        }