Exemple #1
0
        /// <summary>Handles incomming messages. This method is running own the thread created in <see cref="Connect(string, string, int)"/>.</summary>
        /// <param name="messages">Incomming messages.</param>
        private void Handle(IEnumerable <IToAlchemy> messages)
        {
            foreach (var message in messages)
            {
                switch (message)
                {
                case ChatMessageToAlchemy chatMessage:
                    invoke(() => ReceivedMessage?.Invoke(chatMessage.Message));
                    break;

                case SendIngredient ingredient:
                    invoke(() => ReceivedIngredient?.Invoke(ingredient.Ingredient, ingredient.Pipe));
                    break;

                case StartLevel startLevel:
                    invoke(() => LevelStarted?.Invoke(LevelConfig.FromMutable(startLevel.Config)));
                    break;

                case WelcomeAlchemistIAm welcome:
                    invoke(() => Connected?.Invoke(welcome.Username));
                    break;
                }
            }
        }
 public void StartLevel(LevelConfig config) => SendMessage(new StartLevel(config.ToMutable()));