Пример #1
0
        public NSRCcommand SendResponse(String name, NSRCresponse response)
        {
            NSRCserver server = servers.FirstOrDefault(i => i.name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            server.AddResponse(response);
            return(Connect(name));
        }
Пример #2
0
        internal void AddResponse(NSRCresponse response)
        {
            NSRCcommand cmd = SentCommands.FirstOrDefault(i => i.Id == response.Id);

            if (cmd != null)
            {
                cmd.SetResponse(response);
            }
        }
Пример #3
0
        /// <summary>
        /// Запрос на сервер
        /// </summary>
        /// <returns></returns>
        static Boolean callConnect()
        {
            BasicHttpBinding basicHttpBinding     = null;
            EndpointAddress  endpointAddress      = null;
            ChannelFactory <INSRCservice> factory = null;
            INSRCservice serviceProxy             = null;

            Boolean rv = false;

            try
            {
                basicHttpBinding = new BasicHttpBinding();
                basicHttpBinding.Security.Mode = BasicHttpSecurityMode.None;
                endpointAddress = new EndpointAddress(new Uri($"http://{host}:{port}/nsrc_service.asmx"));
                factory         = new ChannelFactory <INSRCservice>(basicHttpBinding, endpointAddress);
                serviceProxy    = factory.CreateChannel();

                NSRCcommand command = serviceProxy.Connect(serverName);
                while (command != null)
                {
                    rv = true;
                    NSRCresponse response = executeCommand(command);
                    command = serviceProxy.SendResponse(serverName, response);
                    timeout = small_timeout; // переключаем в режим частой проверки
                }
                //WriteConsole("command null");

                factory.Close();
                ((ICommunicationObject)serviceProxy).Close();
            }
            catch (Exception ex)
            {
                WriteConsole(ex.Message, true);
            }
            return(rv);
        }