Initializes a new Rooms instance.

 @param users [Users] The User manager.
 @param matrix [Matrix] The Matrix API instance.
 Gets a room by its ID, alias, or name.

 @return [Room,nil] Returns the room instance if the room was found,
   otherwise `nil`.
196555
def [](id)
      return @rooms[id] if id.start_with? '!'

      if id.start_with? '#'
        res = @rooms.find { |_, r| r.canonical_alias == id }
        return res.last if res.respond_to? :last
      end

      res = @rooms.find { |_, r| r.name == id }
      res.last if res.respond_to? :last
    end
833738
function( userID, roomID ) {

		var userCount;

		if( roomUsers[ roomID ] === undefined ) {

			return promise.reject( 'No room with the id: ' + roomID );
		} else {

			var userIDX = roomUsers[ roomID ].indexOf( userID );

			if( userIDX != -1 ) {

				roomUsers[ roomID ].splice( userIDX, 1 );

				userCount = roomUsers[ roomID ].length;

				if( userCount == 0 ) {

					delete roomUsers[ roomID ];
				}

				return promise.resolve( userCount );
			} else {

				return promise.reject( 'User ' + userID + ' is not in the room: ' + roomID );
			}
		}
	}
200040
def get_room
      response = self.class.get(@api.get_room_config[:url],
        :query => {:auth_token => @token }.merge(@api.get_room_config[:query_params]),
        :headers => @api.headers
      )

      ErrorHandler.response_code_to_exception_for :room, room_id, response
      response.parsed_response
    end
502210
def _get_public_room(self, room_name, invitees: List[User]):
        
        room_name_full = f'#{room_name}:{self._server_name}'
        invitees_uids = [user.user_id for user in invitees]

        for _ in range(JOIN_RETRIES):
            # try joining room
            try:
                room = self._client.join_room(room_name_full)
            except MatrixRequestError as error:
                if error.code == 404:
                    self.log.debug(
                        f'No room for peer, trying to create',
                        room_name=room_name_full,
                        error=error,
                    )
                else:
                    self.log.debug(
                        f'Error joining room',
                        room_name=room_name,
                        error=error.content,
                        error_code=error.code,
                    )
            else:
                # Invite users to existing room
                member_ids = {user.user_id for user in room.get_joined_members(force_resync=True)}
                users_to_invite = set(invitees_uids) - member_ids
                self.log.debug('Inviting users', room=room, invitee_ids=users_to_invite)
                for invitee_id in users_to_invite:
                    room.invite_user(invitee_id)
                self.log.debug('Room joined successfully', room=room)
                break

            # if can't, try creating it
            try:
                room = self._client.create_room(
                    room_name,
                    invitees=invitees_uids,
                    is_public=True,
                )
            except MatrixRequestError as error:
                if error.code == 409:
                    msg = (
                        'Error creating room, '
                        'seems to have been created by peer meanwhile, retrying.'
                    )
                else:
                    msg = 'Error creating room, retrying.'

                self.log.debug(
                    msg,
                    room_name=room_name,
                    error=error.content,
                    error_code=error.code,
                )
            else:
                self.log.debug('Room created successfully', room=room, invitees=invitees)
                break
        else:
            # if can't join nor create, create an unnamed one
            room = self._client.create_room(
                None,
                invitees=invitees_uids,
                is_public=True,
            )
            self.log.warning(
                'Could not create nor join a named room. Successfuly created an unnamed one',
                room=room,
                invitees=invitees,
            )

        return room
745725
def enter_room(self, sid, room, namespace=None):
        
        return self.server.enter_room(sid, room,
                                      namespace=namespace or self.namespace)
1336424
function getSyncResponse(roomMembers) {
    const roomResponse = {
        state: {
            events: [
                testUtils.mkEvent({
                    type: 'm.room.encryption',
                    skey: '',
                    content: {
                        algorithm: 'm.megolm.v1.aes-sha2',
                    },
                }),
            ],
        },
    };

    for (let i = 0; i < roomMembers.length; i++) {
        roomResponse.state.events.push(
            testUtils.mkMembership({
                mship: 'join',
                sender: roomMembers[i],
            }),
        );
    }

    const syncResponse = {
        next_batch: 1,
        rooms: {
            join: {},
        },
    };
    syncResponse.rooms.join[ROOM_ID] = roomResponse;
    return syncResponse;
}
623094
def users(options = {})
      batches = Enumerator.new do |y|
        options = options.merge(group_name: @name)
        resp = @client.get_group(options)
        resp.each_page do |page|
          batch = []
          page.data.users.each do |u|
            batch << User.new(
              name: u.user_name,
              data: u,
              client: @client
            )
          end
          y.yield(batch)
        end
      end
      User::Collection.new(batches)
    end
785612
@Override
    public <T extends ApiGameUser> List<T> in(ApiRoom room, Class<?> clazz) {
        Room sfsRoom = CommandUtil.getSfsRoom(room, extension);
        validateRoom(sfsRoom, room);
        return CommandUtil.getApiGameUserList(sfsRoom.getUserList(), clazz);
    }
134691
def join_room(self, room_id_or_alias):
        
        response = self.api.join_room(room_id_or_alias)
        room_id = (
            response["room_id"] if "room_id" in response else room_id_or_alias
        )
        return self._mkroom(room_id)
1301212
function( userId, id ) {

		return this.memory.joinRoom( userId, id )
		.then( function( id ) {

			if( rooms[ id ] === undefined ) {

				rooms[ id ] = room( this.memory, id );	
			}
			
			return promise.resolve( rooms[ id ] );
		}.bind( this ));
	}
1334955
protected function initRoomsTable(): void
    {
        $this->rooms = new Table($this->config['room_rows']);
        $this->rooms->column('value', Table::TYPE_STRING, $this->config['room_size']);
        $this->rooms->create();
    }
1096297
public static ApiRoom getRoomAgent(Room sfsRoom) {
        Object roomAgent = sfsRoom.getProperty(APIKey.ROOM);
        if(roomAgent == null) 
            throw new RuntimeException("Can not get user agent");
        return (ApiRoom)roomAgent;
    }
729938
def initialize_users(self) -> None:
        """"""
        users = self.request('get', pwdgrp_url)
        self.users = Users(users, self.request)
475785
private void createRoom(int index) {
        ApiRoom agent = agents[index];
        try {
            CreateRoomSettings settings = createRoomSettings(agent);
            User owner = CommandUtil.getSfsUser(agent.getOwner(), api);
            Room room = api.createRoom(extension.getParentZone(), settings, owner);
            room.setProperty(APIKey.ROOM, agent);
            agent.setId(room.getId());
            agent.setPasswordProtected(room.isPasswordProtected());
            agent.setCommand(context.command(RoomInfo.class).room(room.getId()));
        }
        catch (SFSCreateRoomException e) {
            throw new IllegalStateException("Can not create room " + agent.getName(), e);
        }
    }
898985
MeetMeRoomImpl getOrCreateRoomImpl(String roomNumber)
    {
        MeetMeRoomImpl room;
        boolean created = false;

        synchronized (rooms)
        {
            room = rooms.get(roomNumber);
            if (room == null)
            {
                room = new MeetMeRoomImpl(server, roomNumber);
                populateRoom(room);
                rooms.put(roomNumber, room);
                created = true;
            }
        }

        if (created)
        {
            logger.debug("Created MeetMeRoom " + roomNumber);
        }

        return room;
    }
516641
def rooms(&callback)
      http(:get, "/rooms.json") do |data, http|
        if data && data[:rooms]
          callback.call(data[:rooms].map{|room| Firering::Room.instantiate(self, room)}) if callback
        else
          logger.error(http.response)
          callback.call([])
        end
      end
    end
413807
def example(host, user, password, token):
    """"""
    client = None
    try:
        if token:
            print('token login')
            client = MatrixClient(host, token=token, user_id=user)
        else:
            print('password login')
            client = MatrixClient(host)
            token = client.login_with_password(user, password)
            print('got token: %s' % token)
    except MatrixRequestError as e:
        print(e)
        if e.code == 403:
            print("Bad username or password")
            exit(2)
        elif e.code == 401:
            print("Bad username or token")
            exit(3)
        else:
            print("Verify server details.")
            exit(4)
    except MissingSchema as e:
        print(e)
        print("Bad formatting of URL.")
        exit(5)
    except InvalidSchema as e:
        print(e)
        print("Invalid URL schema")
        exit(6)
    print("is in rooms")
    for room_id, room in client.get_rooms().items():
        print(room_id)