StrixNetworkSearchRoom Method (ICondition, Int32, Int32, RoomSearchEventHandler, FailureEventHandler, RequestConfig) |
Starts an asynchronous search for match rooms that meet the given criteria.
After search is complete handler callback is invoked with a list of found rooms.
Namespace:
SoftGear.Strix.Unity.Runtime
Assembly:
StrixUnityRuntime (in StrixUnityRuntime.dll) Version: 1.5.0
Syntax Exceptions Remarks
To use this method you have to connect to the master server at least once.
If disconnected, calling this method will reconnect to the master server with the last used host and port parameters.
Possible exception types in FailureEventArgs's cause:Examples Note: Make sure to change the placeholder values of
applicationId and
host to the real ones that can be found on the
Strix Cloud application information tab.
using SoftGear.Strix.Client.Core.Model.Manager.Filter.Builder;
using SoftGear.Strix.Unity.Runtime;
using UnityEngine;
public class StrixSearchRoomExample : MonoBehaviour
{
void Start()
{
var strixNetwork = StrixNetwork.instance;
strixNetwork.applicationId = "00000000-0000-0000-0000-000000000000";
strixNetwork.ConnectMasterServer(
host: "0123456789abcdef01234567.game.strixcloud.net",
connectEventHandler: _ => {
Debug.Log("Connection established.");
strixNetwork.CreateRoom(
new RoomProperties { name = "My Game Room" },
new RoomMemberProperties { name = "My Player Name" },
handler: __ => {
Debug.Log("Room 1 created.");
strixNetwork.SearchRoom(
condition: ConditionBuilder.Builder().Field("name").EqualTo("My Game Room").Build(),
limit: 10,
offset: 0,
handler: searchResults => {
Debug.Log(searchResults.roomInfoCollection.Count + " rooms found.");
foreach (var roomInfo in searchResults.roomInfoCollection)
Debug.Log("Room ID: " + roomInfo.id
+ "\nHost: " + roomInfo.host
+ "\nMember count: " + roomInfo.memberCount
+ "\nCapacity: " + roomInfo.capacity
);
},
failureHandler: searchError => Debug.LogError("Search failed. Reason: " + searchError.cause));
},
failureHandler: createRoomError => Debug.LogError("Could not create room. Reason: " + createRoomError.cause)
);
},
errorEventHandler: connectError => Debug.LogError("Connection failed. Reason: " + connectError.cause)
);
}
}
See Also