Actionscript 3 AS3为什么不是';RTMFP android到android连接?
我正在与AS3 Flash CS6中的netconnection建立连接。当我在Android上测试从PC到应用程序的swf时,它工作正常。但当我在2台android设备上安装应用程序时,它们无法连接。为什么呢?如果我用我的电脑和两台安卓设备进行测试,它也能工作。我怎样才能让它只在两个安卓设备上工作 以下是我使用的代码:Actionscript 3 AS3为什么不是';RTMFP android到android连接?,actionscript-3,p2p,rtmfp,Actionscript 3,P2p,Rtmfp,我正在与AS3 Flash CS6中的netconnection建立连接。当我在Android上测试从PC到应用程序的swf时,它工作正常。但当我在2台android设备上安装应用程序时,它们无法连接。为什么呢?如果我用我的电脑和两台安卓设备进行测试,它也能工作。我怎样才能让它只在两个安卓设备上工作 以下是我使用的代码: var nc:NetConnection; var group:NetGroup; nc = new NetConnection(); nc.addEventListener(
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);
}
我建议在交换机中添加一个默认的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);
}
请注意,
NetStautusEvent
被调度时会出现类似于NetGroup.Connect.Failed
和NetGroup.Connect.Rejected
的消息以及其他可能有用的消息。在开关
中添加一个默认
案例语句可能会有所帮助,以查看当开关不工作时收到的消息类型。开关在两个androids应用程序中都输入此“NetGroup.Connect.Success”。如果我在电脑上启动swf,它们都可以工作。只有Android设备才有可能吗?太好了!在连接消息之后,您可能会收到其他NetStatusEvent。您显示的switch语句没有检查任何其他内容。只是一些解决问题的建议。。。它可能不会成功,但您可以从这些事件中获得的任何其他详细信息可能很有见地。我已将NetGroup.Connect.Failed和NetGroup.Connect.Rejected添加到交换机,但它进入了成功声明。这是预期的,因为您说它已成功连接。我想说的是,在成功的连接尝试之后,可能会有其他消息被发送。我只提到了拒绝/失败消息作为一个例子:)我将在下面发布一个我建议的例子…好的,谢谢。我添加了默认值,但没有任何跟踪。我想代码一定没问题,因为我一打开电脑上的swf版本,它就在两个Android上工作。当它只是从Android连接到Android时,似乎缺少了一些东西。