示例#1
0
        private void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
        {
            byte[] messageBytes = e.Message;
            string message      = Encoding.ASCII.GetString(messageBytes);

            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            // One second bluelights blink
            MqttClient.Publish("trigger", Encoding.UTF8.GetBytes("1000"));

            int points            = CalculatePoints(message);
            var throwReceivedArgs = new OnThrowReceivedArgs()
            {
                Points = points
            };

            OnThrowReceived(throwReceivedArgs);
        }
示例#2
0
        private void MyDartboardListener_ThrowReceivedEvent(object sender, OnThrowReceivedArgs args)
        {
            CurrentGame.AddThrow(args.Points);

            if (CurrentGame.ThrowsCounter <= 3)
            {
                GameScoreUpdated?.Invoke(sender, new OnScoreUpdatedArgs(CurrentGame));
            }

            if (CurrentGame.IsComplete && CurrentGame.TotalScore >= BeerScoreLimit)
            {
                Console.WriteLine("Beer poured!");
                MyBeerPublisher.PourBeer();
                //CurrentGame.Reset();
                Console.WriteLine("Game complete.");
            }
            else if (CurrentGame.IsComplete)
            {
                //CurrentGame.Reset();
                Console.WriteLine("Game complete.");
            }
        }
示例#3
0
 public virtual void OnThrowReceived(OnThrowReceivedArgs args)
 {
     ThrowReceivedEvent?.Invoke(this, args);
 }