AS3为什么RTMFP android不能连接android?

时间:2012-12-25 16:36:09

标签: actionscript-3 p2p rtmfp

我正在与AS3 Flash CS6中的netconnection建立连接。当我从我的PC上测试swf到Android上的应用程序时,它工作正常。但是当我在2个Android设备上安装应用程序时,它们无法连接。这是为什么?如果我用我的PC和两个Android设备测试它也可以。如何只使用两个Android设备?

这是我正在使用的代码:

var nc:NetConnection;
var group:NetGroup;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.connect("rtmfp:");       

function netStatus(event:NetStatusEvent):void{

switch(event.info.code){

    // The connection attempt succeeded
    case "NetConnection.Connect.Success":
        setupGroup();

        break;

    // The NetGroup is successfully constructed and authorized to function.
    case "NetGroup.Connect.Success":


        break;

    // A new group posting is received
    case "NetGroup.Posting.Notify":


        trace("notify");

        break;

      case "NetGroup.SendTo.Notify":
       trace("notify received");

      break;

    // user joins?
    case "NetGroup.Neighbor.Connect":


    break;
}
}

// Create a group 
function setupGroup():void {
// Create a new Group Specifier object
var groupspec:GroupSpecifier = new GroupSpecifier("test");

// Enable posting
groupspec.postingEnabled = true;

//groupspec.routingEnabled=true;


// Specifies whether information about group membership can be exchanged on IP multicast sockets
groupspec.ipMulticastMemberUpdatesEnabled = true;

// Causes the associated NetStream or NetGroup to join the specified IP multicast group and listen to the specified UDP port.
groupspec.addIPMulticastAddress("225.225.0.1:30000");

// Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.
group = new NetGroup(nc,groupspec.groupspecWithAuthorizations());

// Set the NET_STATUS event listener
group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
 }

1 个答案:

答案 0 :(得分:0)

我建议在你的交换机中添加一个默认的case语句。它可能会或可能不会对正在发生的事情有所了解:

switch (event.info.code)
{
    case "NetConnection.Connect.Success":
        // etc... Not showing orig code
        break;
    // rest of the case statements here
    // then lastly add this:
    default:
        trace(event.info.code);
}