Skip to content

0.15.7

Compare
Choose a tag to compare
@github-actions github-actions released this 10 Jan 18:04

New Auth API (https://github.com/colyseus/colyseus/releases/tag/0.15.15)

Define callback for Auth state change:

client.Auth.OnChange((Colyseus.AuthData<User> authData) =>
{
	if (authData.user != null)
	{
		// Logged in!
	}
	else
	{
		// Logged out!
	}
});

Methods:

  • client.Auth.RegisterWithEmailAndPassword()
  • client.Auth.SignInWithEmailAndPassword()
  • client.Auth.SignInAnonymously()
  • client.Auth.SendResetPasswordEmail()
  • client.Auth.SignOut()
  • (❌ OAuth not yet implemented) client.Auth.SignInWithProvider()

Example

class User
{
	public int id;
	public string email;
	public string name;
}

// ...

try
{
	var response = await client.Auth.SignInWithEmailAndPassword<User>("[email protected]", "123456");
	Debug.Log(response.user.id);
	Debug.Log(response.user.email);
	Debug.Log(response.user.name);
}
catch (Colyseus.HttpException e)
{
	// e.Message
	// e.StatusCode
}