我有一个使用 Adobe Cirrus 建立的网络组。所有客户端都可以正常连接并互相看到,因为我会在发布新流时收到事件NetGroup.Neighbor.Connect
。NetGroup.MulticastStream.PublishNotify
但是,如果用户订阅了已发布的流,则发布者不会收到通知(没有 NetStatusEvent 并且没有回调 onPeerConnect 方法)。但是,订阅者可以毫无问题地接收流。
关于非工作 onPeerConnect 方法的所有其他问题都与 NetStream.DIRECT_CONNECTIONS 有关,但就我而言,我使用的是 NetGroup。
这里有什么问题?
// Only the relevant parts, a few things have been stripped (e.g. connect the netGroup only when the NetConnection has been established etc.)
var groupSpecifier:GroupSpecifier = new GroupSpecifier("group");
groupSpecifier.multicastEnabled = true;
groupSpecifier.postingEnabled = true;
groupSpecifier.serverChannelEnabled = true;
groupSpecifier.objectReplicationEnabled = true;
groupSpecifier.ipMulticastMemberUpdatesEnabled = true;
groupSpecifier.routingEnabled = true;
var netGroup:NetGroup = new NetGroup(netConnection, groupSpecifier.groupspecWithAuthorizations());
var netStream:NetStream = new NetStream(netConnection, groupSpecifier.groupspecWithAuthorizations());
netStream.client = {onPeerConnect:onPeerConnect};
netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
// Never gets called
public function onPeerConnect(netStream:NetStream):Boolean {
trace("onPeerConnect: "+netStream.farID);
return true;
}
private function onNetStatus(event:NetStatusEvent):void {
trace(event.info.code);
switch(event.info.code) {
case EventCodes.STREAM_CONNECT_SUCCESS :
netStream.attachCamera(camera);
netStream.attachAudio(microphone);
netStream.publish(streamName);
break;
}
}