↳ Photon Engine Authentication

AirConsole

new AirConsole(opts) → {AirConsoleObject}

Your gateway object to AirConsole. There are getter and setter functions for all properties. Do not access properties of this object directly.
Parameters:
Name Type Description
opts AirConsole~Config Constructor config, see bellow.
Source:
Returns:
The AirConsole object.
Type
AirConsoleObject

Methods

(abstract) onPersistentDataStored(uid)

Gets called when persistent data was stored from storePersistentData().
Parameters:
Name Type Description
uid String The uid for which the data was stored.
Source:

(abstract) onPhotonEngineAuth(ticket)

Gets called when requestPhotonEngineAuth() finished.
Parameters:
Name Type Description
ticket String | null The Photon auth ticket, or null if the request failed.
Version:
  • 1.12.0
Source:

requestPhotonEngineAuth()

Requests a short-lived ticket for Photon Custom Authentication.
Pass the ticket to Photon as the auth parameter "ticket" (AuthenticationValues.AddAuthParameter). Request a new ticket for every connection attempt: tickets expire after 15 minutes. Photon checks the ticket only when the client connects, so a connected session needs no new ticket. The result is delivered to onPhotonEngineAuth.
Version:
  • 1.12.0
Source:
Examples
//  Screen (game)                                AirConsole                  Photon
//       |                                            |                          |
//       | airconsole.requestPhotonEngineAuth()       |                          |
//       |------------------------------------------->|                          |
//       | airconsole.onPhotonEngineAuth(ticket)      |                          |
//       |<-------------------------------------------|                          |
//       | loadBalancingClient.setCustomAuthentication("ticket=" + ticket, Custom)
//       | loadBalancingClient.connectToRegionMaster(region)                     |
//       |---------------------------------------------------------------------->|
//       |                                            |  Photon verifies ticket  |
//       |                                            |<------------------------>|
//       |                                                                       |
//       | Valid ticket:                                                         |
//       | onStateChange(State.JoinedLobby)                                      |
//       |<----------------------------------------------------------------------|
//       | joinRoom(name) or createRoom(name)                                    |
//       |---------------------------------------------------------------------->|
//       | onJoinRoom(createdByMe)                                               |
//       |<----------------------------------------------------------------------|
//       |                                                                       |
//       | Missing or expired ticket:                                            |
//       | onError(PeerErrorCode.NameServerAuthenticationFailed,                 |
//       |         "NameServer authentication failed: 32755 ...")                |
//       |<----------------------------------------------------------------------|
//       | Request a new ticket, then connect again.                             |
// Photon JavaScript SDK. Request a new ticket before every attempt to connect.
airconsole.onPhotonEngineAuth = function (ticket) {
  // Also connect without a ticket. Photon then rejects the connection with
  // CustomAuthenticationFailed, and the player does not connect anonymously.
  loadBalancingClient.setCustomAuthentication(
    'ticket=' + encodeURIComponent(ticket || ''),
    Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom);
  loadBalancingClient.connectToRegionMaster(region);
};
airconsole.requestPhotonEngineAuth();
// Unity with Photon Fusion. The AirConsole Unity plugin has
// AirConsole.instance.RequestPhotonEngineAuth() and the onPhotonEngineAuth event.
//   var authValues = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };
//   authValues.AddAuthParameter("ticket", ticket ?? string.Empty);
//   await runner.StartGame(new StartGameArgs { GameMode = GameMode.Shared, AuthValues = authValues });

storePersistentData(key, value, uid)

Stores a key-value pair persistently on the AirConsole servers. Storage is per game. Total storage can not exceed 1 MB per game and uid. Storage is public, not secure and anyone can request and tamper with it. Do not store sensitive data.
Parameters:
Name Type Description
key String The key of the data entry.
value mixed The value of the data entry.
uid String The uid for which the data should be stored. For controllers, the default is the uid of this device. Screens must provide a valid uid.
Version:
  • 1.9.0 - uid is no longer optional for requests from the screen
Source: