Exemplo n.º 1
0
        public void Should_get_blank_descriptor_for_negative_membership_id()
        {
            var player = new Player_VM {
                MembershipId = "-1"
            };

            var descriptor = player.GetDescriptor();

            Assert.That(descriptor.Item1, Is.Empty);
            Assert.That(descriptor.Item2, Is.Empty);
        }
        public void TrackConnection(Player_VM player, string connectionId)
        {
            lock (SyncRoot)
            {
                ChatUser user;

                if (Persistence.ContainsKey(player.MembershipId))
                {
                    user = Persistence[player.MembershipId];
                }
                else
                {
                    user = new ChatUser(player.MembershipId, player.GetDescriptor().Item1, player.DonatorLevel > 0);
                    Persistence.Add(player.MembershipId, user);
                }

                user.ConnectedWith(connectionId);
            }
        }
Exemplo n.º 3
0
        private void SendNoticeToRoom(string roomName, Player_VM me, string text)
        {
            if (me.BotId < AIStatics.ActivePlayerBotId)
            {
                return;
            }

            var model = new
            {
                User        = me.GetDescriptor().Item1,
                IsStaff     = ChatStatics.Staff.ContainsKey(me.MembershipId),
                Message     = WebUtility.HtmlEncode(text),
                MessageType = Enum.GetName(typeof(MessageType), MessageType.Notification),
                Timestamp   = DateTime.UtcNow.ToUnixTime(),
            };

            if (!ChatStatics.HideOnJoinChat.Contains(me.MembershipId))
            {
                Clients.Group(roomName).addNewMessageToPage(model);
            }
        }