How to Get Room Information Without Actually Joining the Room

There are several options to get rooms information.

The first way is to use the SearchJoinableRoom() method. For example, the following code returns a collection of the first 10 RoomInfo’s.

StrixNetwork.instance.SearchJoinableRoom(100, 0,
    args => {
        foreach (var roomInfo in args.roomInfoCollection) {
            Debug.Log(String.Format("Room {0}, {1}", roomInfo.roomId, roomInfo.name));
        }
    },
    args => {
        Debug.Log("SearchJoinableRoom failed. error = " + args.cause);
    }
);

Here args.roomInfoCollection is a collection of RoomInfo instances. The RoomInfo class has the following fields.

Field name

Type

id

long

roomId

long

name

string

protocol

string

port

int

host

string

isJoinable

bool

isPasswordProtected

bool

properties

IDictionary <string, object>

state

int

memberCount

int

capacity

int

nodeUid

UID

nodeType

int

nodeProperties

IDictionary <string, object>

stringKey

string

key1

double

key2

double

key3

double

key4

double

key5

double

key6

double

key7

double

key8

double

Another way is to use the GetNodeRoom() method, which returns information about a specific room by its primary key. It is a method of CustomizableMatchNodeClient. See the following code.

StrixNetwork.instance.masterSession.nodeClient.GetNodeRoom(
    new GetMessage<CustomizableMatchServerNodeRoom>(roomInfo.roomId),
    args => {
        var room = args.Result.GetModel();
        Debug.Log(String.Format("Room {0}, {1}", room.GetPrimaryKey(), room.GetName()));
    },
    args => {
        Debug.Log("GetNodeRoom failed. error = " + args.Result.ToString());
    }
);

GetNodeRoom() returns an instance of a CustomizableMatchServerNodeRoom. This class provides similar information as the RoomInfo class except that one should use methods to get its information instead of class properties.

The GetMembers() function can return a collection of members of a target room without joining the room itself.

StrixNetwork.instance.roomSession.roomClient.GetMembers(
    new RoomGetMembersMessage<CustomizableMatchRoom>(roomInfo.roomId),
    args => {
        foreach (var member in args.Result.GetMemberCollection()) {
            Debug.Log(String.Format("Member {0}, {1}", member.GetPrimaryKey(), member.GetName()));
        }
    },
    args => {
        Debug.Log("GetRoomMembers failed. error = " + args.Result.ToString());
    }
);

Here GetMembers() returns an instance of ICollection which stores instances of CustomizableMatchRoomMember.