Click or drag to resize

AbstractSessionConnected Event

Fired when the connection is established successfully.

Namespace:  SoftGear.Strix.Unity.Runtime.Session
Assembly:  StrixUnityRuntime (in StrixUnityRuntime.dll) Version: 1.5.0
Syntax
C#
public event StrixNetworkConnectEventHandler Connected

Value

Type: SoftGear.Strix.Unity.Runtime.EventStrixNetworkConnectEventHandler
Examples
public void ConnectedEventSample(string applicationId, string host, string playerName)
{
    StrixNetwork.instance.roomSession.Connected += args => {
        Debug.Log("Room session connection has been established with the following host: "
            + args.session.host
            + ":" + args.session.port
        );
    };

    StrixNetwork.instance.applicationId = applicationId;
    StrixNetwork.instance.ConnectMasterServer(
        host: host,
        connectEventHandler: _ => {
            StrixNetwork.instance.JoinRandomRoom(
                playerName,
                handler: joinRoomResult => { },
                failureHandler: joinRoomError => {
                    StrixNetwork.instance.CreateRoom(
                        new RoomProperties {
                            name = "New Room",
                            capacity = 4,
                        },
                        new RoomMemberProperties {
                            name = playerName
                        },
                        createRoomResult => { },
                        createRoomError => Debug.LogError(
                            "Could not join nor create a room."
                            + " Reasons: " + joinRoomError.cause
                            + "; " + createRoomError.cause
                        )
                    );
                });
        },
        errorEventHandler: connectError => Debug.LogError("Connection failed. Reason: " + connectError.cause)
    );
}
See Also