The function getRoomListFromGroup is not working

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
thinhtd21091
Posts: 10
Joined: 23 Aug 2024, 02:56

The function getRoomListFromGroup is not working

Post by thinhtd21091 »

Code: Select all

function populateRoomsList() {
    let roomsRaw = sfs.roomManager.getRoomListFromGroup("group_1");
    let roomList = [];

    console.log(roomsRaw)
    for (let r in roomsRaw) {
        let room = roomsRaw[r];
        roomList.push(`
            <a href="#" onclick="onRoomSelected({ id: ${room._id}, name: '${room.name.toString()}' })" id="room" class="list-group-item list-group-item-action">${room.name} <p class='itemSub'>Users: ${room._userCount}/${room.maxUsers}</p></a>`);
    }
    $("#list-group").empty()
    $("#list-group").append(roomList.join(','))
}

I have two rooms with the group ID "group_1", but when I call the function `getRoomListFromGroup("group_1")`, it doesn't work. However, it works with the default. I don't understand why. Here is the code on the client side.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: The function getRoomListFromGroup is not working

Post by Lapo »

Hi,
it depends if your client is subscribed to that specific Room Group.
In your zone configuration you can declare which groups are auto-joined by each User as soon as they login. You can find these parameters in your ZoneConfigurator, see attached screenshot.
Screenshot 2024-08-28 alle 08.56.07.png
(24.55 KiB) Not downloaded yet


If the Room group you're trying to access is not subscribed by the client you will get an empty list.

For more info on this topic check the docs here:
https://docs2x.smartfoxserver.com/Devel ... chitecture

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
thinhtd21091
Posts: 10
Joined: 23 Aug 2024, 02:56

Re: The function getRoomListFromGroup is not working

Post by thinhtd21091 »

Hi Labo, I have two issues:
1. When I send a group chat using ModeratorMessageRequest as shown below, I get a log message saying "java.lang.IllegalStateException: Mod Message discarded. No recipients," but using AdminMessageRequest works fine.

Code: Select all

function onSendGroupMessageBtClick() {
    var recipMode = new SFS2X.MessageRecipientMode(SFS2X.MessageRecipientMode.TO_GROUP, "default");
    let isSent = sfs.send(new SFS2X.ModeratorMessageRequest($("#message-input").val(), recipMode));
    if (isSent)
        $("#message-input").val("");

}

2. When I use

Code: Select all

session.setProperty("$permission", DefaultPermissionProfile.MODERATOR)
how can I use custom permissions? I run extension code in JavaScript.
Post Reply