Filter Rooms

Overview

Filters the public rooms of your game in the Lobby server.
Methods
​
FilterRoom(SWLobbyFilterData, byte, Action<bool, SWGetRoomFilterReply, SWLobbyError>)
Called by players to begin an asynchronous operation to filter rooms in the Lobby server using the specified filterData and count.
Class
​
​SWLobbyFilterData​
The filter data object.
​SWGetRoomFilterReply​
The response object when the operation finished successfully.
​SWLobbyError​
The error that occurred when a lobby API operation failed.
Maximum number of indexes of a room is 3.
Maximum page row count is 15.

Example

1
// Creating a new indexData object
2
SWLobbyIndexData indexData = new SWLobbyIndexData();
3
​
4
// Adding a string typed index
5
// with name equals to "level" and
6
// value equals to "hard"
7
indexData.AddIndex("level", "hard");
8
​
9
// Adding a int typed index
10
// with name equals to "rank" and
11
// value equals to 50
12
indexData.AddIndex("rank", 50);
13
​
14
// Using the indexData to create room
15
NetworkClient.Lobby.CreateRoom("new room", true, 4, indexData, (successful, reply, error) =>{
16
if (successful){
17
Debug.Log("Room created " + reply);
18
}
19
else{
20
Debug.Log("Failed to create room " + error);
21
}
22
});
Copied!
1
// Creating a new filterData object
2
SWLobbyFilterData filterData = new SWLobbyFilterData();
3
​
4
// Adding a string typed filter
5
// with name equals to "level" and
6
// value equals to "hard"
7
filterData.AddFilter("level", "hard");
8
​
9
// Adding a int typed index
10
// with name equals to "rank" and
11
// value between 1 to 100
12
filterData.AddFilter("rank", 1, 100);
13
​
14
// Using the filterData to filter rooms
15
// 10 is the max number of return rooms
16
NetworkClient.Lobby.FilterRoom(filterData, 10, (okay, reply, error) =>{
17
if (okay){
18
Debug.Log("Filtered rooms " + reply);
19
}
20
else{
21
Debug.Log("Failed to Filtered rooms " + error);
22
}
23
});
Copied!
Last modified 2yr ago
Copy link