Highlighted

Android LocalConnection issue ?

New Here ,
Jan 17, 2015

Copy link to clipboard

Copied

Hi

My AIR app on Android seems to have a LocalConnection issue.

The app has a Master and Client swf. The Master and Client communicates via LocalConnection sockets.

I don't have any issues on WIndows PC, Windows 8 Surface. But on Android (Samsung Galaxy Table), it is not working.

Curiously enough, the cs6 Debug Launcher for Desktop also has the same problem - ie works for Desktop (Windows) but not Android.

I turned on all permissions in .apk and .air. Also, I made sure to include master.swf and client.swf in the package.

Appended is a reduced program to isolate to key essentials (well, I did leave in some convenient debugging functions)

One would tap on the Master debug text window to pop message to Client Debug Window and vice versa,

Appreciate if anyone can shed some light on this ?

master.fla

----------------

import flash.display.*;

import fl.events.*;

import flash.text.TextField;

import flash.events.Event;

var client_loader:Loader = new Loader();

var client_url:URLRequest = new URLRequest("Client.swf");

var master_access_socket_name:String = "VideoAd_master_access";

var client_access_socket_name:String = "VideoAd_client_access";

var master_socket_name:String = "VideoAd_master";

var client_socket_name:String = "VideoAd_client";

var client_rcv_access:LocalConnection;

var client_snd_access:LocalConnection;

var master_rcv:LocalConnection;

var master_snd:LocalConnection;

var MESSAGE_1:int = 1;

var MESSAGE_2:int = 2;

var MESSAGE_3:int = 3;

var debugText:TextField = new TextField();

debugText.text = "Master Debug Text Window\n";

init_setup();

function init_setup() {

  Multitouch.inputMode=MultitouchInputMode.GESTURE;

    setup_Debug_textfield();

  setup_connection();

  init_client_swf();

}

function write_debug(msg:String)

{

  debugText.appendText(msg);

  debugText.appendText("\n");

}

function setup_Debug_textfield() {

    addChild(debugText);

  debugText.x = 10;

  debugText.y = 10;

  debugText.border = true;

    debugText.borderColor = 0xFF0000;

  debugText.wordWrap = true;

  debugText.width = 250;

    debugText.height = 200;

  debugText.addEventListener(MouseEvent.CLICK, onDebug_click);

}

function onDebug_click(e:MouseEvent):void {

  send_msg(MESSAGE_1, 1, "");

  write_debug("onDebug_click");

}

//**************************** Local Connection Functions *******************

function setup_connection()

{

  trace("****Master");

  master_rcv = new LocalConnection();

  master_rcv.connect(master_socket_name);

  master_rcv.client = this;

  master_rcv.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

  master_snd = new LocalConnection();

  master_snd.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

    master_snd.client = this;

}

function init_client_swf()

{

  addChild(client_loader);

  client_loader.load(client_url);

  //adds an event listener for successful completion of XML load.

  client_loader.addEventListener(Event.COMPLETE, client_loaded);

  client_loader.addEventListener(IOErrorEvent.IO_ERROR, client_errorHandler);

}

function client_errorHandler(event:IOErrorEvent):void {

  trace("******************Error Client file not loaded");

}

//that takes place when XML loading is complete

function client_loaded(event:Event):void {

  trace("******************CLient SWF loaded");

}

function onLocalConnectionStatus(statusEvent:StatusEvent):void

{

  if (statusEvent.level=="error"){

  trace("Master error on LocalConnection");

  }

}

function send_msg(msg_type:int, vidObject_id:int, msg_str:String): void

{

    master_snd.send(client_socket_name, "msgHandler", msg_type, vidObject_id, msg_str);

}

function msgHandler(msg_type:int, id:int, msg_str:String):void {

  trace("***msgHandler *Master msg_type= " + msg_type + " id= " + id + " str=" + msg_str);

    write_debug("msg_type= " + msg_type + " id= " + id);

  switch (msg_type) {

  case MESSAGE_1:

     break;

  case MESSAGE_2:

     break;

  default:

  break;

  }

}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

client.fla

-------------

import flash.display.*;

import fl.events.*;

import flash.text.TextField;

import flash.events.Event;

var master_socket_name:String = "VideoAd_master";

var client_socket_name:String = "VideoAd_client";

var client_snd:LocalConnection;

var client_rcv:LocalConnection;

var MESSAGE_1:int = 1;

var MESSAGE_2:int = 2;

var MESSAGE_3:int = 3;

var debugText:TextField = new TextField();

debugText.text = "Client Debug Text Window\n";

init_setup();

function init_setup() {

  Multitouch.inputMode=MultitouchInputMode.GESTURE;

    setup_Debug_textfield();

  setup_connection();

}

function write_debug(msg:String)

{

  debugText.appendText(msg);

  debugText.appendText("\n");

}

function setup_Debug_textfield() {

    addChild(debugText);

  debugText.x = 300;

  debugText.y = 10;

  debugText.border = true;

    debugText.borderColor = 0xFF0000;

  debugText.wordWrap = true;

  debugText.width = 250;

    debugText.height = 200;

  debugText.addEventListener(MouseEvent.CLICK, onDebug_click);

}

function onDebug_click(e:MouseEvent):void {

  send_msg(MESSAGE_2, 2, "");

  write_debug("onDebug_click");

}

//**************************** Local Connection Functions *******************

function setup_connection()

{

  trace("***Client");

  client_rcv = new LocalConnection();

  client_rcv.connect(client_socket_name);

  client_rcv.client = this;

  client_rcv.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

  client_snd = new LocalConnection();

  client_snd.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

    client_snd.client = this;

}

function onLocalConnectionStatus(statusEvent:StatusEvent):void

{

  if (statusEvent.level=="error"){

  trace("Client error on LocalConnection");

  }

}

function send_msg(msg_type:int, vidObject_id:int, msg_str:String): void

{

    client_snd.send(master_socket_name, "msgHandler", msg_type, vidObject_id, msg_str);

}

function msgHandler(msg_type:int, id:int, msg_str:String):void {

    var rand_str:String;

  trace("***msgHandler *Client msg_type= " + msg_type + " id= " + id + " str=" + msg_str);

    write_debug("msg_type= " + msg_type + " id= " + id);

  switch (msg_type) {

  case MESSAGE_1:

     break;

  case MESSAGE_2:

     break;

  default:

  break;

  }

}

TOPICS
Development

Views

101

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Android LocalConnection issue ?

New Here ,
Jan 17, 2015

Copy link to clipboard

Copied

Hi

My AIR app on Android seems to have a LocalConnection issue.

The app has a Master and Client swf. The Master and Client communicates via LocalConnection sockets.

I don't have any issues on WIndows PC, Windows 8 Surface. But on Android (Samsung Galaxy Table), it is not working.

Curiously enough, the cs6 Debug Launcher for Desktop also has the same problem - ie works for Desktop (Windows) but not Android.

I turned on all permissions in .apk and .air. Also, I made sure to include master.swf and client.swf in the package.

Appended is a reduced program to isolate to key essentials (well, I did leave in some convenient debugging functions)

One would tap on the Master debug text window to pop message to Client Debug Window and vice versa,

Appreciate if anyone can shed some light on this ?

master.fla

----------------

import flash.display.*;

import fl.events.*;

import flash.text.TextField;

import flash.events.Event;

var client_loader:Loader = new Loader();

var client_url:URLRequest = new URLRequest("Client.swf");

var master_access_socket_name:String = "VideoAd_master_access";

var client_access_socket_name:String = "VideoAd_client_access";

var master_socket_name:String = "VideoAd_master";

var client_socket_name:String = "VideoAd_client";

var client_rcv_access:LocalConnection;

var client_snd_access:LocalConnection;

var master_rcv:LocalConnection;

var master_snd:LocalConnection;

var MESSAGE_1:int = 1;

var MESSAGE_2:int = 2;

var MESSAGE_3:int = 3;

var debugText:TextField = new TextField();

debugText.text = "Master Debug Text Window\n";

init_setup();

function init_setup() {

  Multitouch.inputMode=MultitouchInputMode.GESTURE;

    setup_Debug_textfield();

  setup_connection();

  init_client_swf();

}

function write_debug(msg:String)

{

  debugText.appendText(msg);

  debugText.appendText("\n");

}

function setup_Debug_textfield() {

    addChild(debugText);

  debugText.x = 10;

  debugText.y = 10;

  debugText.border = true;

    debugText.borderColor = 0xFF0000;

  debugText.wordWrap = true;

  debugText.width = 250;

    debugText.height = 200;

  debugText.addEventListener(MouseEvent.CLICK, onDebug_click);

}

function onDebug_click(e:MouseEvent):void {

  send_msg(MESSAGE_1, 1, "");

  write_debug("onDebug_click");

}

//**************************** Local Connection Functions *******************

function setup_connection()

{

  trace("****Master");

  master_rcv = new LocalConnection();

  master_rcv.connect(master_socket_name);

  master_rcv.client = this;

  master_rcv.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

  master_snd = new LocalConnection();

  master_snd.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

    master_snd.client = this;

}

function init_client_swf()

{

  addChild(client_loader);

  client_loader.load(client_url);

  //adds an event listener for successful completion of XML load.

  client_loader.addEventListener(Event.COMPLETE, client_loaded);

  client_loader.addEventListener(IOErrorEvent.IO_ERROR, client_errorHandler);

}

function client_errorHandler(event:IOErrorEvent):void {

  trace("******************Error Client file not loaded");

}

//that takes place when XML loading is complete

function client_loaded(event:Event):void {

  trace("******************CLient SWF loaded");

}

function onLocalConnectionStatus(statusEvent:StatusEvent):void

{

  if (statusEvent.level=="error"){

  trace("Master error on LocalConnection");

  }

}

function send_msg(msg_type:int, vidObject_id:int, msg_str:String): void

{

    master_snd.send(client_socket_name, "msgHandler", msg_type, vidObject_id, msg_str);

}

function msgHandler(msg_type:int, id:int, msg_str:String):void {

  trace("***msgHandler *Master msg_type= " + msg_type + " id= " + id + " str=" + msg_str);

    write_debug("msg_type= " + msg_type + " id= " + id);

  switch (msg_type) {

  case MESSAGE_1:

     break;

  case MESSAGE_2:

     break;

  default:

  break;

  }

}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

client.fla

-------------

import flash.display.*;

import fl.events.*;

import flash.text.TextField;

import flash.events.Event;

var master_socket_name:String = "VideoAd_master";

var client_socket_name:String = "VideoAd_client";

var client_snd:LocalConnection;

var client_rcv:LocalConnection;

var MESSAGE_1:int = 1;

var MESSAGE_2:int = 2;

var MESSAGE_3:int = 3;

var debugText:TextField = new TextField();

debugText.text = "Client Debug Text Window\n";

init_setup();

function init_setup() {

  Multitouch.inputMode=MultitouchInputMode.GESTURE;

    setup_Debug_textfield();

  setup_connection();

}

function write_debug(msg:String)

{

  debugText.appendText(msg);

  debugText.appendText("\n");

}

function setup_Debug_textfield() {

    addChild(debugText);

  debugText.x = 300;

  debugText.y = 10;

  debugText.border = true;

    debugText.borderColor = 0xFF0000;

  debugText.wordWrap = true;

  debugText.width = 250;

    debugText.height = 200;

  debugText.addEventListener(MouseEvent.CLICK, onDebug_click);

}

function onDebug_click(e:MouseEvent):void {

  send_msg(MESSAGE_2, 2, "");

  write_debug("onDebug_click");

}

//**************************** Local Connection Functions *******************

function setup_connection()

{

  trace("***Client");

  client_rcv = new LocalConnection();

  client_rcv.connect(client_socket_name);

  client_rcv.client = this;

  client_rcv.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

  client_snd = new LocalConnection();

  client_snd.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);

    client_snd.client = this;

}

function onLocalConnectionStatus(statusEvent:StatusEvent):void

{

  if (statusEvent.level=="error"){

  trace("Client error on LocalConnection");

  }

}

function send_msg(msg_type:int, vidObject_id:int, msg_str:String): void

{

    client_snd.send(master_socket_name, "msgHandler", msg_type, vidObject_id, msg_str);

}

function msgHandler(msg_type:int, id:int, msg_str:String):void {

    var rand_str:String;

  trace("***msgHandler *Client msg_type= " + msg_type + " id= " + id + " str=" + msg_str);

    write_debug("msg_type= " + msg_type + " id= " + id);

  switch (msg_type) {

  case MESSAGE_1:

     break;

  case MESSAGE_2:

     break;

  default:

  break;

  }

}

TOPICS
Development

Views

102

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 17, 2015 0

Have something to add?

Join the conversation