Click or drag to resize

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
C#
public void SetRoom(
	long roomId,
	RoomProperties roomProperties,
	RoomSetEventHandler handler,
	FailureEventHandler failureHandler,
	RequestConfig config = null
)

Parameters

roomId
Type: SystemInt64
ID of the match room.
roomProperties
Type: SoftGear.Strix.Unity.RuntimeRoomProperties
New values of the room properties.
handler
Type: SoftGear.Strix.Unity.Runtime.EventRoomSetEventHandler
This callback is invoked when the changes have been applied successfully.
failureHandler
Type: SoftGear.Strix.Unity.Runtime.EventFailureEventHandler
This callback is invoked in case of a failure.
config (Optional)
Type: SoftGear.Strix.Client.Core.RequestRequestConfig
If not null, used to configure the request timeout. Default timeout is 30 seconds. See RequestConfig for more details.
Exceptions
ExceptionCondition
NullReferenceExceptionThrown if roomProperties is null.
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:
ErrorCodeException Strix error which can be further separated by an error code:
ConnectionErrorFailed to send the request because of a connection error.
RequestTimeoutServer did not respond within the specified timeout interval.
ModelNotFoundCould not find the room with the given ID.
NoSuchPropertyCould not find one of the properties to set.
LockTimeout
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