예제 #1
0
        public object arg;            // void *arg

        public PollProcedure(PollProcedure next, double nextTime, PollHandler handler, object arg)
        {
            this.next      = next;
            this.nextTime  = nextTime;
            this.procedure = handler;
            this.arg       = arg;
        }
예제 #2
0
        public void SendPoll(string mes, string chatId, string replyText, string type = "Message")
        {
            string JSONMarkup = PollHandler.NewPoll(mes, replyText);

            if (JSONMarkup == "" || replyText == "" || replyText == null)
            {
                this.SendMessage("Ваш запрос не отвечает требованиям", chatId);
                return;
            }
            PollHandler.polls[PollHandler.polls.Length - 1].chat_id = chatId;
            JSONNode N;
            string   otladka = Link + Token + "/sendMessage?chat_id=" + chatId + "&text=" + replyText + "&reply_markup=" + JSONMarkup;

            try
            {
                using (TelegramRequest.webBot) {
                    string resp = TelegramRequest.webBot.DownloadString(otladka);

                    N = JSON.Parse(resp);
                    PollHandler.polls[PollHandler.polls.Length - 1].message_id = N["result"]["message_id"];
                }
            }
            catch
            {
                Console.WriteLine(mes + "\n" + chatId + "\n" + type + "\n" + otladka);
                return;
            }
        }
예제 #3
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            _instance = this;
        }

        _miniWait   = new WaitForSeconds(_miniDelayLength);
        _shortWait  = new WaitForSeconds(_shortDelayLength);
        _mediumWait = new WaitForSeconds(_mediumDelayLength);
        _longWait   = new WaitForSeconds(_longDelayLength);

        informationManager = GameObject.Find("InformationManager").GetComponent <InformationManager>();
        scenarioManager    = GameObject.Find("ScenarioManager").GetComponent <ScenarioManager>();
        audioManager       = GameObject.Find("AudioManager").GetComponent <AudioManager>();
        characterHandler   = GetComponent <CharacterHandler>();
        itemHandler        = GetComponent <ItemHandler>();
        interfaceHandler   = GetComponent <InterfaceHandler>();
        eventHandler       = GetComponent <EventHandler>();
        pollHandler        = GetComponent <PollHandler>();
        arrowHandler       = GetComponent <ArrowHandler>();
        twitchManager      = GameObject.Find("TwitchManager").GetComponent <TwitchManager>();

        OnRessourceValueChange += VariableChangeRessourcesHandler;
    }
예제 #4
0
        public IEnumerable<string> Transact(IEnumerable<string> message)
        {
            Func<Socket> create = () =>
            {
                var c = _context.Socket(SocketType.REQ);
                c.Connect(_uri);
                return c;
            };

            var control = _singletonSocket ? _control : create();

            List<string> response = null;

            var handle = new PollHandler((s, m) => response = s.RecvAll(Encoding.UTF8).ToList());

            control.PollInHandler += handle;

            message.Take(message.Count() - 1).ToList().ForEach(line=>control.SendMore(line, Encoding.UTF8));

            if (control.Send(message.Last(), Encoding.UTF8) != SendStatus.Sent) return null;

            Context.Poller(CommandTimeoutMicroseconds, control);
            control.PollInHandler -= handle;

            if (!_singletonSocket) control.Dispose();

            if (response == null) throw new TimeoutException(string.Format("Endpoint {0} did not reply within {1} ms.", _uri, (CommandTimeoutMicroseconds/1000)));
            return response;
        }
예제 #5
0
        public async Task ShouldReturnGenericCommandResultSucessTrueWhenGetPollByIdCommandIsValid()
        {
            PollHandler _handler = new PollHandler(new FakePollRepository(), _mockLogger.Object);
            var         result   = (GenericCommandResult)await _handler.Handle(_getPollByIdCommandValid);

            Assert.IsTrue(_getPollByIdCommandValid.Valid);
            Assert.AreEqual(true, result.Success);
        }
예제 #6
0
 public RunManager(RestClient client, Args args, string fullPathReportName)
 {
     _client = client;
     _logger = client.Logger;
     _args = args;
     _fullPathReportName = fullPathReportName;
     _runHandler = new RunHandlerFactory().Create(client, args.RunType, args.EntityId);
     _pollHandler = new PollHandlerFactory().Create(client, args.RunType, args.EntityId);
 }
        public override void Given()
        {
            CancellationToken = new CancellationTokenSource().Token;
            Query             = new Mock <IEpcisQuery>();
            Request           = new PollRequest {
                QueryName = "UnknownQuery", Parameters = null
            };
            Handler = new PollHandler(new[] { Query.Object });

            Query.SetupGet(x => x.Name).Returns("ExampleQuery");
        }
예제 #8
0
        public override void Given()
        {
            CancellationToken = new CancellationTokenSource().Token;
            Query             = new Mock <IEpcisQuery>();
            Request           = new PollRequest {
                QueryName = "ExampleQuery", Parameters = null
            };
            Handler = new PollHandler(new [] { Query.Object });

            Query.SetupGet(x => x.Name).Returns("ExampleQuery");
            Query.Setup(x => x.Handle(It.IsAny <QueryParameter[]>(), CancellationToken)).Returns(Task.FromResult(new PollResponse()));
        }
예제 #9
0
        public async Task <ActionResult <GenericCommandResult> > Get(Guid id, [FromServices] PollHandler handler)
        {
            var ret = (GenericCommandResult)await handler.Handle(new UpdatePollByIdCommand(id));

            if (!ret.Success)
            {
                _logger.LogWarning("Get --> {Id}", id, ret);
                return(BadRequest(ret));
            }
            _logger.LogInformation("Get --> {Id}", id, ret);

            return(Ok(ret));
        }
예제 #10
0
        public void Disconnect()
        {
            lock (this)
            {
                try
                {
                    if (nStream != null && !cancelToken.IsCancellationRequested)
                    {
                        cancelToken.Cancel();
                        OnPoll = null;

                        nStream.Close();
                        client.Close();

                        nStream = null;
                        client  = null;

                        if (SyncContext != null)
                        {
                            SyncContext.Post((state) =>
                            {
                                if (OnDisconnected != null)
                                {
                                    OnDisconnected(this);
                                }
                            }, null);
                        }
                        else
                        {
                            if (OnDisconnected != null)
                            {
                                OnDisconnected(this);
                            }
                        }
                    }
                }
                catch//(Exception e)
                {
                    //Util.Log("Disconnect" + e.Message);
                }
            }
        }
예제 #11
0
        public async Task <ActionResult <GenericCommandResult> > Post([FromBody] CreatePollCommand command, [FromServices] PollHandler handler)
        {
            //var user = User.Claims.FirstOrDefault(x=>x.Type == "user_id")?.Value;
            var ret = (GenericCommandResult)await handler.Handle(command);

            if (!ret.Success)
            {
                _logger.LogWarning("Post --> ", ret);
                return(BadRequest(ret));
            }
            _logger.LogInformation("Post --> ", ret);
            return(Ok(ret));
        }
예제 #12
0
        public PollHandler procedure; // void (*procedure)();

        #endregion Fields

        #region Constructors

        public PollProcedure(PollProcedure next, double nextTime, PollHandler handler, object arg)
        {
            this.next = next;
            this.nextTime = nextTime;
            this.procedure = handler;
            this.arg = arg;
        }