예제 #1
0
 private void ServerListenLoop()
 {
     while (true)
     {
         var client = listener.AcceptTcpClient();
         tcp = new TcpSession(client, configuration.Certificate, Authenticate, logger, true);
         var session = new NodeSession(tcp, logger);
         session.OnAuthenticated += (local, remote) => OnClientAuthenticated(session);
         // TODO handle connection state changed
         session.Run();
     }
 }
예제 #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);
            }
        }