I'm trying to communicate from the browser with a 3rd party video conferencing app running on my local machine using Flex/Flash. The idea being that users can login on our webpage, the page in turn tells the local app to open and go to the proper chat room. Flash is needed as a bridge to bypass the mixed sources warning. My AS code:
public function Check():void {
import flash.events.SecurityErrorEvent;
import flash.external.ExternalInterface;
import flash.net.Socket;
import flash.system.Security;
var mySocket:Socket = new Socket();
Security.loadPolicyFile('xmlsocket://127.0.0.1:63457');
mySocket.addEventListener(Event.CONNECT, onConnect);
mySocket.addEventListener(Event.CLOSE,onClose);
mySocket.addEventListener(IOErrorEvent.IO_ERROR, onError);
mySocket.addEventListener(ProgressEvent.SOCKET_DATA, onProgress);
mySocket.addEventListener(DataEvent.DATA, onData);
mySocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
function onConnect(event:Event):void {
trace('connect');
}
function onClose(event:Event):void {
trace('close');
}
function onProgress(event:ProgressEvent):void {
trace('Progressevent fired');
var output:String = mySocket.readUTFBytes(mySocket.bytesAvailable);
ExternalInterface.call("alert", output);
}
function onData(event:DataEvent):void {
trace('onData fired');
}
function onSecurityError(event:ErrorEvent) : void {
trace("SECURITY ERROR : " + event.text);
ExternalInterface.call("alert", 'error: ' + event.text, 0);
}
function onError(event:ErrorEvent) : void {
trace("ERROR : " + event.text);
ExternalInterface.call("alert", 'error: ' + event.text, 0);
}
mySocket.connect("127.0.0.1", 63457);
mySocket.writeMultiByte('GET /?url=http://app.mydomain.com HTTP/1.1', 'UTF-8');
mySocket.flush();
};
Running locally all goes well and the 'onProgress' listener is fired and I see the app responding to the request . Running from a different domain however fails. I do not get sandbox errors, it's just like the call isn't happening. Remote debugger suggest that the connection is made successfully.
As you can probably see from the code I am a beginner at AS3 but I did quite a bit of research before asking this question here. I hope someone can help. Tried this code in Flash Pro, Flash Builder (both as AS Project and Flex Project), same results.