Ejemplo n.º 1
0
        public void JoinedEvent(string newRoomIdString)
        {
            Guid newRoomId = new Guid(newRoomIdString);
            var pairs = repo.GetUserOnline().ConnIdRoomIdPairs;
            repo.GetUserOnline().LastResponse = DateTime.Now;

            foreach (var room in pairs.Where(uo => uo.RoomId != newRoomId))
            {
                DoLeave(room.RoomId);
            }

            if (pairs.Where(uo => uo.RoomId == newRoomId).Where(uo => uo.ConnIdString == Context.ConnectionId).Count() > 0)
            {
                return;
            }

            Groups.Add(Context.ConnectionId, newRoomIdString);

            if (pairs.Where(uo => uo.RoomId == newRoomId).Count() == 0)
            {
                SendUserList(newRoomIdString);
                SendSystemMessage(newRoomIdString, "К нам присоединился " + repo.CurrentUser().Nickname);
            }

            var pair = new UserConnIdRoomId();
            pair.ConnIdString = Context.ConnectionId;
            pair.RoomId = new Guid(newRoomIdString);
            repo.GetUserOnline().ConnIdRoomIdPairs.Add(pair);
        }
Ejemplo n.º 2
0
        public void JoinedEvent(string newRoomIdString)
        {
            Guid newRoomId = new Guid(newRoomIdString);
            var  pairs     = repo.GetUserOnline().ConnIdRoomIdPairs;

            repo.GetUserOnline().LastResponse = DateTime.Now;

            foreach (var room in pairs.Where(uo => uo.RoomId != newRoomId))
            {
                DoLeave(room.RoomId);
            }

            if (pairs.Where(uo => uo.RoomId == newRoomId).Where(uo => uo.ConnIdString == Context.ConnectionId).Count() > 0)
            {
                return;
            }

            Groups.Add(Context.ConnectionId, newRoomIdString);

            if (pairs.Where(uo => uo.RoomId == newRoomId).Count() == 0)
            {
                SendUserList(newRoomIdString);
                SendSystemMessage(newRoomIdString, "К нам присоединился " + repo.CurrentUser().Nickname);
            }

            var pair = new UserConnIdRoomId();

            pair.ConnIdString = Context.ConnectionId;
            pair.RoomId       = new Guid(newRoomIdString);
            repo.GetUserOnline().ConnIdRoomIdPairs.Add(pair);
        }