StrixNetworkSetRoom Method (Int64, RoomProperties, RoomSetEventHandler, FailureEventHandler, RequestConfig) |
Changes the properties of an existing match room.
Namespace:
SoftGear.Strix.Unity.Runtime
Assembly:
StrixUnityRuntime (in StrixUnityRuntime.dll) Version: 1.5.0
Syntax Exceptions Remarks
To use this method you must be the room's owner.
You cannot change primaryKey, ownerUid, and memberCount using this method.
List of parameters available for changing:
- name - The name of the room.
- capacity - Maximum number of room members.
- password - Room entry password.
- state - An integer value that can be used for application's own purposes.
- isJoinable - Determines if new players are allowed to join the room.
- key1 - An arbitrary double value that can be used for application's own purposes.
- key2 - An arbitrary double value that can be used for application's own purposes.
- key3 - An arbitrary double value that can be used for application's own purposes.
- key4 - An arbitrary double value that can be used for application's own purposes.
- key5 - An arbitrary double value that can be used for application's own purposes.
- key6 - An arbitrary double value that can be used for application's own purposes.
- key7 - An arbitrary double value that can be used for application's own purposes.
- key8 - An arbitrary double value that can be used for application's own purposes.
- stringKey - An arbitrary string value that can be used for application's own purposes.
Possible exception types in FailureEventArgs's cause:Examples
In this example we first connect to a master server to be able to create a new room. Then we create a match room for up to 20 members and give it a name.
We check and output to log the room's current capacity by reading
StrixNetwork.instance.room.GetCapacity() right after creating the room.
Then we change the capacity from 20 to 15 and print it again to see if the new value was applied successfully.
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.Unity.Runtime;
using UnityEngine;
public class StrixConnectTest : 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(
roomProperties: new RoomProperties {
name = "Wildwood",
password = "66e3f2nk",
capacity = 20
},
memberProperties: new RoomMemberProperties {
name = "Artemis"
},
handler: __ => {
Debug.Log("Room created. Current capacity: " + strixNetwork.room.GetCapacity());
strixNetwork.SetRoom(
roomId: strixNetwork.roomSession.room.GetPrimaryKey(),
roomProperties: new RoomProperties {
capacity = 15
},
handler: setRoomResult => Debug.Log("Capacity changed. Current capacity: " + strixNetwork.room.GetCapacity()),
failureHandler: setRoomError => Debug.LogError("Search failed. Reason: " + setRoomError.cause)
);
},
failureHandler: createRoomError => Debug.LogError("Could not create room. Reason: " + createRoomError.cause)
);
},
errorEventHandler: connectError => Debug.LogError("Connection failed. Reason: " + connectError.cause)
);
}
}
See Also