1 Reply Latest reply on May 12, 2010 8:12 PM by Michael Thornburgh

    how can get total neighborCount from netGroup?

    jDeepa

      hi,
      Iam using stratus with flex 3, it's working fine.

      my question is , when 'NetGroup.Connect.Success ' event happend  I need to get the  neighborCount value from this event. unfortunately neighborCount value always 0. But this value only chnaged when 'NetGroup.Neighbor.Connect' event happen. Is it possible to get current  neighborCount value before  'NetGroup.Neighbor.Connect' event triger ?
      any help?

       

      netConnection = new NetConnection();
      netConnection.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
      netConnection.connect(SERVER + DEVKEY);

       

      private function NetStatusHandler(e:NetStatusEvent):void {
         switch (e.info.code) {
          case "NetConnection.Connect.Success":
            OnConnect();
            break;
         case "NetGroup.Connect.Success":
           trace(e.info.group.neighborCount)   // this value always 0. ----  but in debugging mode , this showing proper count
           OnNetGroupConnect(e.info.group);
           break;               
        case "NetGroup.Posting.Notify":
          OnPosting(e.info.message);
          break;
        case "NetGroup.SendTo.Notify":
        case "NetGroup.Neighbor.Connect":
          trace("neigbourConnect:  " + netGroup.neighborCount)
          break;
        case "NetGroup.Neighbor.Disconnect":
          mx.controls.Alert.show("User Disconnected:")      

          break;          
      }               
      }

       

      private function OnConnect():void {
         var groupSpecifier:GroupSpecifier
         groupSpecifier = new GroupSpecifier(GROUP_PREFIX + groupName);
         groupSpecifier.multicastEnabled = true;
         groupSpecifier.postingEnabled = true;
         groupSpecifier.serverChannelEnabled = true;
         groupSpecifier.objectReplicationEnabled = true
         netGroup = new NetGroup(netConnection, groupSpecifier.groupspecWithoutAuthorizations());
        netGroup.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
      }

        • 1. Re: how can get total neighborCount from netGroup?
          Michael Thornburgh Adobe Employee

          no.  NetGroup.neighborCount is the number of members of the group that are directly connected to you.  when you first join the group, you have no neighbors, so the neighbor count is 0.  for each NetGroup.Neighbor.Connect event, the neighbor count should increase.  however, due to event queuing, it may occasionally (and temporarily) be the case that NetGroup.neighborCount is higher or lower than (count(NetGroup.Neighbor.Connect events received) - count(NetGroup.Neighbor.Disconnect events received)).

           

          RTMFP Groups are cooperative, distributed constructs.  the only information available to your node about the group as a whole is what can be deduced from local information.  the number of neighbors that you have is an exact count of the number of direct connections, but your node isn't necessarily directly connected to all other members of the group.  NetGroup.estimatedMemberCount uses the group addresses of some of your directly connected neighbors and the even distribution of group addresses to estimate the total number of members of the group, but that number is just an estimate (and it may even be lower than the number of neighbors you have!).  you must have at least 4 neighbors before the estimatedMemberCount will begin estimating (below that it is just neighbors + 1).

           

          it may take 10 to 20 seconds (or more, for very large groups) for a new member to fully settle into its right place in the group.  groups are continuously optimizing themselves, so neighbors come and go.

          1 person found this helpful