我们正在运行一个积云服务器来进行实时语音和文本聊天。
设置是每个客户端可以通过group.post()在同一个group.post()中将数据发布到彼此的客户端。不幸的是,这个函数非常慢(至少延迟了半秒),所以我们转而使用NetStream.send来调用其他客户端上的函数,通过它传递数据。这几乎立即起作用了。
然而,我们现在正在尝试使用不同的NetGroups构建单独的聊天室。但是当这样做时,NetStream.send()不再工作了,其他客户端永远不会调用函数,也不会传输语音数据。基本上,整个发布的NetStream似乎不再工作了。
我们有以下设置来在每个客户端上建立一个NetGroup和一个发布流:
var gspec:GroupSpecifier = new GroupSpecifier("Group1");
gspec.multicastEnabled = true;
gspec.postingEnabled = true;
gspec.serverChannelEnabled = true;
gspec.objectReplicationEnabled = true;
gspec.routingEnabled = true;
_group = new NetGroup(_netConnection, gspec.groupspecWithAuthorizations());
_group.addEventListener(NetStatusEvent.NET_STATUS, handleNetGroupStatus);
_sendStream = new NetStream(_netConnection, gspec.groupspecWithAuthorizations());
_sendStream.addEventListener(NetStatusEvent.NET_STATUS, handleNetStreamStatus);
_sendStream.client = this;
_sendStream.attachAudio(_mic);
_sendStream.publish("media");下面的代码用于侦听"media“流:
case "NetGroup.Neighbor.Connect":
var netStream :NetStream = new NetStream(_netConnection, p_netStatusEvent.info.peerID);
netStream.addEventListener(NetStatusEvent.NET_STATUS, handleNetStreamStatus);
netStream.client = this;
netStream.play("media");
break;NetGroup连接本身可以工作,当邻居连接时,每个客户端都会调用"NetGroup.Neighbor.Connect“。但是_sendStream本身根本不起作用。没有收到任何数据,也没有调用任何函数。
在以下列方式构造发布NetStream时,它确实可以工作:
_sendStream = new NetStream(_netConnection, NetStream.DIRECT_CONNECTIONS); 但是,我们只希望NetStream发送到单个NetGroup,而根据Adobe文档,在构造函数中使用Adobe文档应该正好允许这一点。
我们是不是漏掉了什么?
发布于 2012-04-18 09:55:20
我找到了答案:
您还必须让接收到的gspec.groupspecWithAuthorizations()听p_netStatusEvent.info.peerID.而不是p_netStatusEvent.info.peerID.
这确实管用。不幸的是,这使得语音聊天变得不可能,因为它非常慢(和NetGroup.post()一样慢),并且引入了许多声音工件。
所以,我们得为不同的聊天室找到另一个解决方案.
https://stackoverflow.com/questions/10206097
复制相似问题