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); }
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."); } }
public virtual void OnThrowReceived(OnThrowReceivedArgs args) { ThrowReceivedEvent?.Invoke(this, args); }