Пример #1
0
        private bool TrySetSession(NodeSession session, PeerSession peer)
        {
            if (peer.TrySetSession(session))
            {
                return(true);
            }

            session.Disconnect(DisconnectReason.CannotSetSession);
            return(false);
        }
Пример #2
0
        public void Start_()
        {
            var isError = false;

            try
            {
                client.Connect(endpoint);

                // we should create the node session here to mirror the server
                if (!NodeSession.Run())
                {
                    return;
                }
            }
            catch (SocketException socketException) // Host down
            {
                if (socketException.SocketErrorCode == SocketError.ConnectionRefused)
                {
                }
                if (socketException.SocketErrorCode == SocketError.HostDown)
                {
                }
                if (socketException.SocketErrorCode == SocketError.TimedOut)
                {
                }
                isError = true;
            }
            catch (Exception e)
            {
                isError = true;
            }

            if (isError)
            {
                // WTF ? why not close client
                NodeSession.Disconnect(DisconnectReason.CannotConnectToNode);
            }
        }
Пример #3
0
 private void CloseSession(NodeSession session, DisconnectReason reason)
 {
     session.Disconnect(reason);
 }