2 Replies Latest reply on Sep 8, 2011 2:35 PM by valentin86

    onPeerConnect not working with NetGroup

    valentin86 Level 1

      I have a NetGroup established using Cirrus. All clients can connect fine and see each other, since I receive NetGroup.Neighbor.Connect and NetGroup.MulticastStream.PublishNotify events when a new stream is being published.


      However, if a user subscribes to a published stream, the publisher does not receive a notification at all (no NetStatusEvent and no callback to the onPeerConnect method). The subscriber receives the stream without problems, though.
      Is this related to the use of NetGroup? Does onPeerConnect only work with DIRECT_CONNECTIONS? How can I control the access to a published stream?


      Do you see a mistake?


      Thank you!

      // 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());


      // NetStream is being established after NetGroup.Connect.Success

      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 {


          switch(event.info.code) {
                 case EventCodes.STREAM_CONNECT_SUCCESS :

        • 1. Re: onPeerConnect not working with NetGroup
          Michael Thornburgh Adobe Employee

          onPeerConnect only happens for DIRECT_CONNECTIONS NetStreams.


          you control access to a multicast stream by controlling access to the group. the group specification ("groupspec") is a capability and, if you want to control access, should be treated like a shared password. you can make the groupspec hard to guess by including pseudorandom text in the group name (in the constructor for GroupSpecifier) or by using GroupSpecifier.makeUnique().  in the latter case you will need to generate the groupspec in a central location and only give it out to authorized clients.

          • 2. Re: onPeerConnect not working with NetGroup
            valentin86 Level 1

            Thank you so much for your explanation!


            Please do us all a favor and ask the responsible persons to add this information (onPeerConnect only for DIRECT_CONNECTIONS) to the onPeerConnect method description in the language reference.


            Thanks again.