Click or drag to resize

StrixNetworkSetRoom Method (Int64, IDictionaryString, Object, 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,
	IDictionary<string, Object> roomProperties,
	RoomSetEventHandler handler,
	FailureEventHandler failureHandler,
	RequestConfig config = null
)

Parameters

roomId
Type: SystemInt64
ID of the match room.
roomProperties
Type: System.Collections.GenericIDictionaryString, Object
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.
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. When using this overload, properties are set by means of a dictionary, so you have to be careful to provide the values of the correct type. In this example if we used 15.0 or 15f instead of 15 the request would fail since capacity's type is int. To find out the expected types, please refer to the RoomProperties class.
using SoftGear.Strix.Unity.Runtime;
using System.Collections.Generic;
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 Dictionary<string, object> {
                        { "name", "Wildwood" },
                        { "password", "66e3f2nk" },
                        { "capacity", 20 }
                    },
                    playerName: "Artemis",
                    handler: __ => {
                        Debug.Log("Room created. Current capacity: " + strixNetwork.room.GetCapacity());

                        strixNetwork.SetRoom(
                            roomId: strixNetwork.roomSession.room.GetPrimaryKey(),
                            roomProperties: new Dictionary<string, object> {
                                { "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