Updating Room Member Information

Once a client joins the room, they can always change the properties of their room member. Only the client represented by the room member can change its properties. This means that not even the room owner has the privilege of modifying another member’s information.

To do this you can call one of the following methods on the StrixNetwork singleton.

void SetRoomMember(long memberId, RoomMemberProperties memberProperties, RoomMemberSetEventHandler handler, FailureEventHandler failureHandler, RequestConfig config = null)
void SetRoomMember(long memberId, IDictionary<string, object> memberProperties, RoomMemberSetEventHandler handler, FailureEventHandler failureHandler, RequestConfig config = null)

The second overload is provided for convenience if you have the new values for the modified properties stored as a string-keyed dictionary.

Code Example

using SoftGear.Strix.Unity.Runtime;
using UnityEngine;

public class StrixSetRoomMemberTest : MonoBehaviour
{
    void Start()
    {
        var strixNetwork = StrixNetwork.instance;

        // This is a placeholder value. Change this to your application ID
        // It can be found on the Strix Cloud application information tab: https://www.strixcloud.net/app/applist
        strixNetwork.applicationId = "00000000-0000-0000-0000-000000000000";

        // First we connect to the master server
        strixNetwork.ConnectMasterServer(
            // This is a placeholder value. Change this to your master hostname
            // It can be found on the Strix Cloud application information tab: https://www.strixcloud.net/app/applist
            host: "000000000000000000000000.game.strixcloud.net",
            connectEventHandler: _ => {
                Debug.Log("Connection established.");

                // After we've connected to the master server we can create a room
                strixNetwork.CreateRoom(
                    roomProperties: new RoomProperties {
                        name = "Wildwood",
                        password = "66e3f2nk",                          // This room will be password-protected so clients without the password won't be able to join it
                        capacity = 20                                   // The maximum number of clients the room will hold
                    },
                    memberProperties: new RoomMemberProperties {
                        name = "Artemis"                                // This will be the name of our player
                    },
                    handler: createRoomResult => {
                        Debug.Log("Room created. Current member name: " + strixNetwork.selfRoomMember.GetName());

                        // Now that the room is created let's try to change the player's name
                        strixNetwork.SetRoomMember(
                            memberId: strixNetwork.selfRoomMember.GetPrimaryKey(),      // The ID of the player
                            memberProperties: new RoomMemberProperties {
                                name = "Marianne"                                       // Change the name from Artemis to Marianne
                            },
                            handler: setRoomMemberResult => Debug.Log("Member name changed. Current name: " + strixNetwork.selfRoomMember.GetName()),       // Printing the new name
                            failureHandler: setRoomMemberError => Debug.LogError("SetRoomMember failed. Reason: " + setRoomMemberError.cause)
                        );
                    },
                    failureHandler: createRoomError => Debug.LogError("Could not create room. Reason: " + createRoomError.cause)
                );
            },
            errorEventHandler: connectError => Debug.LogError("Connection failed. Reason: " + connectError.cause)
        );
    }
}

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.