Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Change the generator or C# source instead of hand editing generated JS.
`Assets/AirConsole/scripts/Editor/BuildAutomation/` is the build generation area.
Sample scenes live under the AirConsole assets tree.
`.compound-engineering/solutions/` contains documented solutions to past problems, organized by category with YAML frontmatter (module, tags, problem_type).
## NAMING
New public C# events use PascalCase: `OnSafeAreaChanged`, `OnPhotonEngineAuth`.
Older camelCase events such as `onReady` and `onMessage` stay as they are. Rename one only with a deprecation plan.
When a private handler would share the event name, name it `Handle<Event>`: `HandlePhotonEngineAuth`.
## WHERE TO LOOK
Main SDK: `Assets/AirConsole/scripts/Runtime/AirConsole.cs`.
Android bridge: `Assets/AirConsole/plugins/Android/`.
Expand Down
2 changes: 1 addition & 1 deletion Assets/AirConsole/examples/basic/controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>

<style type=text/css>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>

<style type=text/css>
html, body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<title>Controller - Game states</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<script>
// The view manager finds all div containers with the "view" class and lets me show one view
// while hiding all others.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<style type=text/css>
/* the style sheet dictates what our elements (buttons, backgrounds etc.) will look like. */
#background {
Expand Down
2 changes: 1 addition & 1 deletion Assets/AirConsole/examples/pong/controller.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<script>
const LOBBY = "LOBBY";
const GAME = "GAME";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<style type=text/css>
/* the style sheet dictates what our elements (buttons, backgrounds etc.) will look like. */

Expand Down
2 changes: 1 addition & 1 deletion Assets/AirConsole/examples/swipe/swipe-controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<script>
/* ------------PLEASE READ THIS-----------
* this script has been copied from https://github.com/AirConsole/airconsole-controls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<style>

.text {
Expand Down
2 changes: 1 addition & 1 deletion Assets/AirConsole/extras/controller-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<style type=text/css>
/* the style sheet dictates what our elements (buttons, backgrounds etc.) will look like. */

Expand Down
30 changes: 30 additions & 0 deletions Assets/AirConsole/scripts/Runtime/AirConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public enum AndroidUIResizeMode {

public delegate void OnPersistentDataLoaded(JToken data);

public delegate void OnPhotonEngineAuth(string ticket);

public delegate void OnPremium(int deviceId);

public delegate void OnPause();
Expand Down Expand Up @@ -250,6 +252,12 @@ public static AirConsole instance {
/// <param name="data">An object mapping uids to all key value pairs.</param>
public event OnPersistentDataLoaded onPersistentDataLoaded;

/// <summary>
/// Gets called when RequestPhotonEngineAuth() finished.
/// </summary>
/// <param name="ticket">The Photon auth ticket, or null if the request failed.</param>
public event OnPhotonEngineAuth OnPhotonEngineAuth;

/// <summary>
/// Gets called when a device becomes premium or when a premium device connects.
/// <param name="deviceId">The device id of the premium device.</param>
Expand Down Expand Up @@ -1022,6 +1030,21 @@ public void RequestPersistentData(List<string> uids) {
wsListener.Message(msg);
}

/// <summary>
/// Requests a short-lived ticket for Photon Custom Authentication.
/// Pass it to Photon with <c>AuthenticationValues.AddAuthParameter("ticket", ticket)</c>.
/// Request a new ticket for every connection attempt: tickets expire after 15 minutes.
/// Requires airconsole-api 1.12.0 or newer. Will call OnPhotonEngineAuth when done.
/// </summary>
/// <exception cref="NotReadyException">Thrown if the AirConsole Unity Plugin is not ready.</exception>
public void RequestPhotonEngineAuth() {
if (!IsAirConsoleUnityPluginReady()) {
throw new NotReadyException();
}

wsListener.Message(new JObject { { "action", "requestPhotonEngineAuth" } });
}

/// <summary>
/// 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.
Expand Down Expand Up @@ -1231,6 +1254,7 @@ private void InitWebSockets() {
wsListener.onHighScoreStored += OnHighScoreStored;
wsListener.onPersistentDataStored += OnPersistentDataStored;
wsListener.onPersistentDataLoaded += OnPersistentDataLoaded;
wsListener.OnPhotonEngineAuth += HandlePhotonEngineAuth;
wsListener.onPremium += OnPremium;
wsListener.onPause += OnPause;
wsListener.onResume += OnResume;
Expand Down Expand Up @@ -1716,6 +1740,7 @@ private void UnsubscribeWebSocketEvents() {
wsListener.onHighScoreStored -= OnHighScoreStored;
wsListener.onPersistentDataStored -= OnPersistentDataStored;
wsListener.onPersistentDataLoaded -= OnPersistentDataLoaded;
wsListener.OnPhotonEngineAuth -= HandlePhotonEngineAuth;
wsListener.onPremium -= OnPremium;
wsListener.onPause -= OnPause;
wsListener.onResume -= OnResume;
Expand Down Expand Up @@ -1874,6 +1899,11 @@ private void OnPersistentDataStored(JObject msg) {
}
}

private void HandlePhotonEngineAuth(JObject msg) {
string ticket = (string)msg["ticket"];
eventQueue.Enqueue(delegate() { OnPhotonEngineAuth?.Invoke(ticket); });
}

private void OnPersistentDataLoaded(JObject msg) {
try {
JToken data = msg["data"];
Expand Down
2 changes: 1 addition & 1 deletion Assets/AirConsole/scripts/Runtime/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace NDream.AirConsole {
public static class Settings {
public static readonly Version RequiredMinimumVersion = new(1, 11, 0);
public static readonly Version RequiredMinimumVersion = new(1, 12, 0);
public const string VERSION = "2.6.3";

// ReSharper disable once UnusedMember.Global // Used by AirConsole on Android only
Expand Down
4 changes: 4 additions & 0 deletions Assets/AirConsole/scripts/Runtime/WebsocketListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class WebsocketListener : WebSocketBehavior {
public event Action<JObject> onHighScoreStored;
public event Action<JObject> onPersistentDataStored;
public event Action<JObject> onPersistentDataLoaded;
public event Action<JObject> OnPhotonEngineAuth;
public event Action<JObject> onPremium;
public event Action<JObject> onPause;
public event Action<JObject> onResume;
Expand Down Expand Up @@ -147,6 +148,9 @@ public void ProcessMessage(string data) {
case "onPersistentDataLoaded":
onPersistentDataLoaded?.Invoke(msg);
break;
case "onPhotonEngineAuth":
OnPhotonEngineAuth?.Invoke(msg);
break;
case "onPremium":
onPremium?.Invoke(msg);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ App.prototype.initAirConsole = function() {
});
};

me.airconsole.onPhotonEngineAuth = function(ticket) {
me.postToUnity({
"action": "onPhotonEngineAuth",
"ticket": ticket
});
};

me.airconsole.onPremium = function(device_id) {
me.postToUnity({
"action": "onPremium",
Expand Down Expand Up @@ -421,6 +428,8 @@ App.prototype.processUnityData = function (data) {
this.airconsole.storeHighScore(data.level_name, data.level_version, data.score, data.uid, data.data, data.score_string);
} else if (data.action == "requestPersistentData") {
this.airconsole.requestPersistentData(data.uids);
} else if (data.action == "requestPhotonEngineAuth") {
this.airconsole.requestPhotonEngineAuth();
} else if (data.action == "storePersistentData") {
this.airconsole.storePersistentData(data.key, data.value, data.uid);
} else if (data.action == "setImmersiveState") {
Expand Down
2 changes: 1 addition & 1 deletion Assets/WebGLTemplates/AirConsole-2020/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

var isUnityEditor = !!getURLParameterByName("unity-editor-websocket-port");
</script>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<script src="airconsole-unity-plugin.js"></script>
<script src="airconsole-settings.js"></script>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ App.prototype.initAirConsole = function() {
});
};

me.airconsole.onPhotonEngineAuth = function(ticket) {
me.postToUnity({
"action": "onPhotonEngineAuth",
"ticket": ticket
});
};

me.airconsole.onPremium = function(device_id) {
me.postToUnity({
"action": "onPremium",
Expand Down Expand Up @@ -421,6 +428,8 @@ App.prototype.processUnityData = function (data) {
this.airconsole.storeHighScore(data.level_name, data.level_version, data.score, data.uid, data.data, data.score_string);
} else if (data.action == "requestPersistentData") {
this.airconsole.requestPersistentData(data.uids);
} else if (data.action == "requestPhotonEngineAuth") {
this.airconsole.requestPhotonEngineAuth();
} else if (data.action == "storePersistentData") {
this.airconsole.storePersistentData(data.key, data.value, data.uid);
} else if (data.action == "setImmersiveState") {
Expand Down
2 changes: 1 addition & 1 deletion Assets/WebGLTemplates/AirConsole-U6/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

var isUnityEditor = !!getURLParameterByName("unity-editor-websocket-port");
</script>
<script src="https://www.airconsole.com/api/airconsole-1.11.0.js"></script>
<script src="https://www.airconsole.com/api/airconsole-1.12.0.js"></script>
<script src="airconsole-unity-plugin.js"></script>
<script src="airconsole-settings.js"></script>
<script>
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Release notes follow the [keep a changelog](https://keepachangelog.com/en/1.1.0/

### Added

- **Unity API:** `RequestPhotonEngineAuth` and the `OnPhotonEngineAuth` event provide a ticket for Photon Custom Authentication. Requires airconsole-api 1.12.0.

## [2.6.3] - 2026-10-03

### Fixed
Expand Down
Loading