Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

- Declaration

public static void AuthenticateAsGuest(string server, string userName, Action<CavrnusAuthentication> onSuccess, Action<string> onFailure)

- Description

Creates a guest user account with a given name and joins as that user.

...

onSuccess provides a CavrnusAuthentication which you can then store/load on your local machine to use on a future run without requiring the user to re-login.

- Sample

Code Block
using CavrnusSdk.API;
using UnityEngine;

public class AuthenticateAsGuest : MonoBehaviour
{
    private const string MyServer = "cavrnus.cavrn.us";

    void Start()
    {
        CavrnusFunctionLibrary.AuthenticateAsGuest(MyServer, "Cavrnus Guest User",
            auth => OnAuthComplete(auth), error => OnAuthFailure(error));
    }

    private void OnAuthComplete(CavrnusAuthentication auth)
    {
        Debug.Log("Authentication complete!  Welcome to Cavrnus!");
    }

    private void OnAuthFailure(string error)
    {
        Debug.LogError("Failed to login: " + error);
    }
}