예제 #1
0
        private void ReceiveLoop()
        {
            while (true)
            {
                var message = ReceiveNextMessage();
                OnMessageReceived(message);

                switch (message)
                {
                case CallbackMessage callback:
                    _context.Post(_ =>
                    {
                        var oldValues = callback.Registers.ToArray();
                        var eventArgs = new HookEventArgs(callback.Registers);
                        OnHookTriggered(eventArgs);

                        var continueMessage = new ContinueMessage(callback.Id);
                        for (int i = 0; i < callback.Registers.Count; i++)
                        {
                            if (oldValues[i] != callback.Registers[i])
                            {
                                continueMessage.RegisterChanges[i] = callback.Registers[i];
                            }
                        }

                        Send(continueMessage);
                        WaitForAcknowledgement();
                    }, null);
                    break;

                default:
                    _bufferedMessages.Add(message);
                    break;
                }
            }
        }
예제 #2
0
 public override void Handle(ContinueMessage message)
 {
     base.Handle(new ContinueMessage());
     _verCheck = 0;
     _horCheck = 0;
 }