Exemple #1
0
        public void CreateMessage()
        {
            var message = new ConnectSessionMessage(TestHelpers.GetTestUser(1), "/connect 12");

            message.Sessionid.Should().Be(12);
            message.IsValid.Should().BeTrue();
        }
Exemple #2
0
        public void CreateMessage3()
        {
            var message = new ConnectSessionMessage(TestHelpers.GetTestUser(1), "/connect qw");

            message.Sessionid.Should().Be(0);
            message.IsValid.Should().BeFalse();
        }
Exemple #3
0
        public void PublishMessage(Message message)
        {
            var user = new PokerUser(message.Chat);

            var estimation = new EstimationMessage(user, message.Text);

            if (estimation.IsValid)
            {
                bus.Publish(estimation);
                return;
            }

            if (message.Text.StartsWith("/"))
            {
                var command = message.Text.Split(' ');
                switch (command[0].ToLower())
                {
                case "/startsession":
                    bus.Publish(new StartSessionMessage(user, message.Text));
                    return;

                case "/connect":
                    var connectMessage = new ConnectSessionMessage(user, message.Text);
                    bus.Publish(connectMessage);
                    return;

                case "/poker":
                    bus.Publish(new StartPokerMessage(user, message.Text));
                    return;

                case "/endpoker":
                    bus.Publish(new CancelPokerMessage(user, message.Text));
                    return;

                case "/leavesession":
                    bus.Publish(new LeaveSessionMessage(user, message.Text));
                    return;

                case "/showusers":
                    bus.Publish(new GetSessionUsersMessage(user, message.Text));
                    return;

                case "/showsessions":
                    bus.Publish(new ShowSessionsMessage(user, message.Text));
                    return;

                default:
                    bus.Publish(new UnknownCommandMessage(user, message.Text));
                    return;
                }
            }

            bus.Publish(new UnknownCommandMessage(user, message.Text));
        }
Exemple #4
0
 public void Handle(ConnectSessionMessage message)
 {
     if (message.IsValid)
     {
         service.ConnectToSession(message.User, message.Sessionid, message.MessageId);
     }
     else
     {
         service.SendConnections(message.User);
     }
 }
Exemple #5
0
        public void PublishMessage(CallbackQuery callbackQuery)
        {
            PokerUser pokerUser = new PokerUser(callbackQuery.From);

            var estimation = new EstimationMessage(pokerUser, callbackQuery.Data, callbackQuery.Message.MessageId);

            if (estimation.IsValid)
            {
                bus.Publish(estimation);
                return;
            }

            var connectMessage = new ConnectSessionMessage(pokerUser, callbackQuery.Data, callbackQuery.Message.MessageId);

            bus.Publish(connectMessage);
        }