Click or drag to resize

StrixNetworkJoinRandomRoom Method (RoomMemberProperties, RoomJoinEventHandler, FailureEventHandler, RequestConfig)

Joins a random match room.

Namespace:  SoftGear.Strix.Unity.Runtime
Assembly:  StrixUnityRuntime (in StrixUnityRuntime.dll) Version: 1.5.0
Syntax
C#
public void JoinRandomRoom(
	RoomMemberProperties memberProperties,
	RoomJoinEventHandler handler,
	FailureEventHandler failureHandler,
	RequestConfig config = null
)

Parameters

memberProperties
Type: SoftGear.Strix.Unity.RuntimeRoomMemberProperties
These properties are set for your member after the room has been joined successfully.
handler
Type: SoftGear.Strix.Unity.Runtime.EventRoomJoinEventHandler
This callback is invoked when the room has been joined 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
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.
NoRoomsAvailableCould not find joinable rooms.
RoomNotFoundCould not leave the current room before joining a new one. Either the room does not exist or you're not a member of this room.
AlreadyInRoomYou are already joined to the room you're trying to join.
RoomFullOfMembersThe room you're trying to join has no room for new members.
WrongRoomPasswordThe room you're trying to join is password-protected and either you didn't provide any password or it didn't match.
RoomNotJoinableCannot join the room because its owner has made it non-joinable.
LockTimeout
MaxRoomCountReached
NoSuchProperty
InvalidCredentialsType Credentials type does not match the server authentication configuration. This can happen if, for example, the server is configured to authenticate by password instead of application ID. On Strix Cloud this error should never occur since currently it always uses application ID authentication.
InternalError Internal server error. This can be caused by a bug or some other problem on the server and should be reported to the developers.
UnsupportedLibraryVersion Current client library is not supported by the server. This can happen if the client version is too old. To fix this error, update the Strix SDK to the latest version.
InvalidApplicationIdToken Application ID token provided via applicationId does not match the one on the server. Check if the application ID is the same as the one listed on Information tab of the Dashboard on the Strix Cloud web page.
SocketExceptionAn error occurred when attempting to access the socket.
WebException There has been an error when connecting to the authentication server.
It's either an HTTP error such as 404/Not Found, or a network error like failure to resolve a DNS entry, a socket error, etc.
ArgumentException When using an authentication server this error can happen if the server returns an invalid authorization token.
It could be an invalid UTF-8 string or an invalid JSON.
Exception This can happen if the address for the given host couldn't be resolved when establishing socket connection.
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.Unity.Runtime;
using System.Collections.Generic;
using UnityEngine;

public class StrixJoinRandomRoomExample : 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.JoinRandomRoom(
                    memberProperties: new RoomMemberProperties {
                        name = "My Player Name",
                        properties = new Dictionary<string, object> {
                            { "hairColor", "green" }
                        }
                    },
                    handler: __ => Debug.Log("Room joined."),
                    failureHandler: joinError => Debug.LogError("Joining random room failed. Reason: " + joinError.cause)
                );
            },
            errorEventHandler: connectError => Debug.LogError("Connection failed. Reason: " + connectError.cause)
        );
    }
}
See Also