Copy link to clipboard
Copied
There is no supported library, I try to load paho-mqtt.js(Release Eclipse Photon v1.1.0 · eclipse/paho.mqtt.javascript · GitHub), but there are many errors:
import flash.filesystem.File;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.Security;
import flash.system.SecurityDomain;
// Load Paho MQTT library file
var mqttLoader: URLLoader = new URLLoader();
mqttLoader.addEventListener(Event.COMPLETE, onMqttLibLoaded);
mqttLoader.load(new URLRequest(File.applicationDirectory.resolvePath("libs/paho-mqtt-min.js").nativePath));
// Callback function when Paho MQTT library is loaded
function onMqttLibLoaded(event: Event): void {
// Execute Paho MQTT library in a security sandbox
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var mqttScript: String = event.target.data;
var mqttLoader: Loader = new Loader();
mqttLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMqttLibReady);
}
// Callback function when Paho MQTT library is ready
function onMqttLibReady(event: Event): void {
// Use Paho MQTT library for MQTT communication
var client: MQTTClient = new MQTTClient("127.0.0.1", 8883, "clientId");
client.connect();
}
Copy link to clipboard
Copied
you're loading a javascript file with as3. that's going to be problematic.