コード例 #1
0
    public static void StartListening(BizDomain equityDomain)
    {
        ManualResetEvent waitForConnect = new ManualResetEvent(false);
        ClientService    ClientTask;
        IPAddress        localAddr = IPAddress.Parse("127.0.0.1");

        // Client Connections Pool
        ClientConnectionPool ConnectionPool = new ClientConnectionPool();

        // Client Task to handle client requests
        ClientTask = new ClientService(ConnectionPool);

        ClientTask.Start();

        TcpListener listener = new TcpListener(localAddr, portNum);

        try
        {
            listener.Start();

            int TestingCycle = 3; // Number of testing cycles
            int ClientNbr    = 0;

            // Start listening for connections.
            Console.WriteLine("Waiting for a connection...");
            while (TestingCycle > 0 && EquityMatchingEngine.OMEHost.running == true)
            {
                TcpClient handler = listener.AcceptTcpClient();

                if (handler != null)
                {
                    Console.WriteLine("Client#{0} accepted!", ++ClientNbr);

                    // An incoming connection needs to be processed.
                    ConnectionPool.Enqueue(new ClientHandler(handler, equityDomain));

                    //--TestingCycle;
                }
                else
                {
                    break;
                }

                waitForConnect.WaitOne(100); //
            }
            waitForConnect.WaitOne(1000);
            listener.Stop();
            Console.WriteLine("Order Listener Stoped");
            // Stop client requests handling
            ClientTask.Stop();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }

        //Console.WriteLine("\nHit enter to continue...");
        //Console.Read();
    }
コード例 #2
0
    public static void StartListening()
    {
        ClientService ClientTask  ;

        // Client Connections Pool
        ClientConnectionPool ConnectionPool = new ClientConnectionPool()  ;

        // Client Task to handle client requests
        ClientTask = new ClientService(ConnectionPool) ;

        ClientTask.Start() ;

        TcpListener listener = new TcpListener(portNum);
        try
        {
            listener.Start();

            int TestingCycle = 3 ; // Number of testing cycles
            int ClientNbr = 0 ;

            // Start listening for connections.
            Console.WriteLine("Waiting for a connection...");
            while ( TestingCycle > 0 )
            {

                TcpClient handler = listener.AcceptTcpClient();

                if (  handler != null)
                {
                    Console.WriteLine("Client#{0} accepted!", ++ClientNbr) ;

                    // An incoming connection needs to be processed.
                    ConnectionPool.Enqueue( new ClientHandler(handler) ) ;

                    //--TestingCycle ;
                }
                else
                    break;
            }
            listener.Stop();

            // Stop client requests handling
            ClientTask.Stop() ;

        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }

        Console.WriteLine("\nHit enter to continue...");
        Console.Read();
    }
コード例 #3
0
ファイル: TcpServer3.cs プロジェクト: lihaosky/Utils
    public static void StartListening()
    {
        ClientService ClientTask;

        // Client Connections Pool
        ClientConnectionPool ConnectionPool = new ClientConnectionPool();

        // Client Task to handle client requests
        ClientTask = new ClientService(ConnectionPool);

        ClientTask.Start();

        TcpListener listener = new TcpListener(portNum);

        try {
            listener.Start();

            int TestingCycle = 3;    // Number of testing cycles
            int ClientNbr    = 0;

            // Start listening for connections.
            Console.WriteLine("Waiting for a connection...");
            while (TestingCycle > 0)
            {
                TcpClient handler = listener.AcceptTcpClient();

                if (handler != null)
                {
                    Console.WriteLine("Client#{0} accepted!", ++ClientNbr);

                    // An incoming connection needs to be processed.
                    ConnectionPool.Enqueue(new ClientHandler(handler));

                    --TestingCycle;
                }
                else
                {
                    break;
                }
            }
            listener.Stop();

            // Stop client requests handling
            ClientTask.Stop();
        } catch (Exception e) {
            Console.WriteLine(e.ToString());
        }

        Console.WriteLine("\nHit enter to continue...");
        Console.Read();
    }
コード例 #4
0
        public GatewayClientFactory(ILoggerFactory loggerFactory,
                                    IMessageCenter messageCenter,
                                    IPlacement placement,
                                    ClientConnectionPool clientPool
                                    )
        {
            this.logger               = loggerFactory.CreateLogger("GatewayClient");
            this.messageCenter        = messageCenter;
            this.placement            = placement;
            this.clientConnectionPool = clientPool;

            this.placement.RegisterServerChangedEvent(this.OnAddServer, this.OnRemoveServer, this.OnOfflineServer);
            this.placement.OnException(this.OnPDKeepAliveException);
        }
コード例 #5
0
ファイル: MessageCenter.cs プロジェクト: egmkang/koala
 public bool SendMessageToServer(long serverID, object message)
 {
     if (this.clientConnectionPool == null)
     {
         this.clientConnectionPool = this.serviceProvider.GetRequiredService <ClientConnectionPool>();
     }
     if (this.clientConnectionPool != null)
     {
         var channel = this.clientConnectionPool.GetChannelByServerID(serverID);
         if (channel != null)
         {
             this.SendMessage(new OutboundMessage(channel, message));
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
ファイル: Brain.cs プロジェクト: robbietherobot/robbie
        /// <summary>
        /// Constructs a new brain object.
        /// </summary>
        /// <param name="visionPreview">A capture element that is placed on a canvas used for capturing what Robbie sees.</param>
        /// <param name="previewCanvas">A canvas element used for rendering the image preview showing what Robbie sees.</param>
        /// <param name="audioPlaybackElement">A media element that is placed on a canvas used for speaking.</param>
        public Brain(CaptureElement visionPreview, Canvas previewCanvas, MediaElement audioPlaybackElement)
        {
            utterancePrediction = new UtterancePrediction();

            ears  = new Ears();
            voice = new Voice(audioPlaybackElement);
            eyes  = new Eyes(visionPreview, previewCanvas);

            pool = new ClientConnectionPool();

            currentIdentityPersonId = AnonymousPersonId;

            // define the event handlers for handling the different events occuring from all the senses
            ears.SpeechRecognized += Ears_SpeechRecognized;
            ears.EarsStateChanged += Ears_EarsStateChanged;
            voice.FinishedPlaybackEventHandler += Voice_FinishedPlayback;
            eyes.NewActivePersonEvent          += Eyes_NewActivePersonEvent;

            // always start in a sleeping state (not actively listening)
            sleeping = true;
        }
コード例 #7
0
        public GatewayMessageHandler(IServiceProvider serviceProvider,
                                     IMessageCenter messageCenter,
                                     ILoggerFactory loggerFactory,
                                     IConnectionManager sessionManager,
                                     IPlacement placement)

        {
            this.serviceProvider      = serviceProvider;
            this.logger               = loggerFactory.CreateLogger("MessageHandler");
            this.messageCenter        = messageCenter;
            this.sessionManager       = sessionManager;
            this.placement            = placement;
            this.clientConnectionPool = serviceProvider.GetService <ClientConnectionPool>();

            this.messageCenter.RegisterMessageProc(new BlockMessageCodec().CodecName, this.ProcessWebSocketMessage, false);
            this.messageCenter.RegisterDefaultMessageProc(this.ProcessDefaultMessage);
            this.RegisterHandler <ResponseAccountLogin>(this.ProcessResponseAccountLogin);
            this.RegisterHandler <RequestCloseSession>(this.ProcessRequestCloseSession);
            this.RegisterHandler <RequestSendMessageToSession>(this.ProcessRequestSendMessageToSession);
            this.RegisterHandler <RequestHeartBeat>(this.ProcessRequestHeartBeat);
            this.RegisterHandler <ResponseHeartBeat>(this.ProcessResponseHeartBeat);
        }
コード例 #8
0
    public static void StartListening()
    {
        var ConnectionPool = new ClientConnectionPool();
        var ClientTask     = new ClientService(ConnectionPool);

        ClientTask.Start();

        var listener = new TcpListener(portNum);

        try
        {
            listener.Start();

            int ClientNbr = 0;

            // Start listening for connections.
            Console.WriteLine("Waiting for a connection...");

            while (true)
            {
                TcpClient handler = listener.AcceptTcpClient();

                if (handler != null)
                {
                    Console.WriteLine("Client#{0} accepted!", ++ClientNbr);
                    ConnectionPool.Enqueue(new ClientHandler(handler));
                }

                Thread.Sleep(1);
            }

            //listener.Stop();
            //ClientTask.Stop();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
    }
コード例 #9
0
 public ClientService(ClientConnectionPool ConnectionPool)
 {
     this.ConnectionPool = ConnectionPool;
 }
コード例 #10
0
 public ClientService(ClientConnectionPool ConnectionPool)
 {
     this .ConnectionPool = ConnectionPool ;
 }
コード例 #11
0
ファイル: WebRequestor.cs プロジェクト: bm98/FSimTrack
 /// <summary>
 /// cTor: submit the webserver as host:port (localhost:8080  or 192.168.1.10:9000 ..)
 /// </summary>
 /// <param name="host_port">Host and port to use in http request</param>
 public WebRequestor( )
 {
     m_client         = new HttpClient( );
     m_connectionPool = new ClientConnectionPool( );
 }