예제 #1
0
        public void ConnectAIClient()
        {
            if (socketEndpointOptions != null)
            {
                int millisecondsTimeout;

                if (socketEndpointOptions.MillisecondsTimeout <= 0)
                {
                    millisecondsTimeout = Timeout.Infinite;
                }
                else
                {
                    millisecondsTimeout = socketEndpointOptions.MillisecondsTimeout;
                }

                if (aiClient != null)
                {
                    aiClient.Disconnect();
                }

                aiClient = new AIClient(this.socketEndpointOptions);

                aiClient.OnOutput += StoreOutputEvent;

                hasSubscribed = true;

                aiCancelTokenSource = new CancellationTokenSource();
                ClientConnectionPacket aiClientPacket = new ClientConnectionPacket(this.aiClient, aiCancelTokenSource.Token, millisecondsTimeout);

                ThreadPool.QueueUserWorkItem(ConnectClient, aiClientPacket);
            }
            else
            {
                throw new CognigyNullOptionsException();
            }
        }
예제 #2
0
        private void ConnectClient(object stateInfo)
        {
            ClientConnectionPacket clientPacket = (ClientConnectionPacket)stateInfo;

            clientPacket.Client.Connect(clientPacket.Token, clientPacket.MillisecondsTimeout);
        }