0 Replies Latest reply on May 20, 2010 10:14 AM by jaydub17

    NetGroup Connection Not Reporting Neighbor Connected Event

    jaydub17

      Our app was working yesterday and now for whatever reason we don't see a neighbor.connected.success event and the peers don't seem to be responding to eachother.  you can see our demo at: http://gab-err.appspot.com/a/P2PMulti.html,  any two pc's connecting will be use the same group name: group1.   the NetGroup.Connect.Success event fires successfully but that's it, the Multicast.Stream.Publish and Neighbor.Connect.Success never fire. thanks guys.

       

       

      Here's our source for the connection:

       

      private const SERVER:String = 'rtmfp://stratus.adobe.com/5b6708e640918da6e8586117-977937ad98db/';

       

      public var seq_num:int = 0;

       

      public function MulticastP2PConnection()

      {

      super();

      _eventDispatcher = new EventDispatcher();

      Debug.warning('latest::MulticastP2PConnection');

      Debug.warning('build 1636');

       

      }

       

      public function get primary():Boolean

      {

      return _primary;

      }

       

      public function set primary(value:Boolean):void

      {

      Debug.warning('setting primary ' + value);

      _primary = value;

      }

       

      public function init(group_name:String) {

       

      this.group_name = group_name;

       

      // start outgoing connection

      net_connection = new NetConnection();

      net_connection.addEventListener(NetStatusEvent.NET_STATUS, on_net_status);

      net_connection.connect(SERVER);

      }

       

      public function close_all_connections():void {

       

      if (net_connection != null) {

      net_stream.close();

      net_stream = null;

      net_group.close();

      net_group = null;

      net_connection.close();

      net_connection = null;

      }

       

      if (incomming_connection != null) {

      incomming_stream.close();

      incomming_stream = null;

      incomming_connection.close();

      incomming_connection = null;

      }

       

      }

       

      private function on_net_status(evt:NetStatusEvent):void {

       

      Debug.log ("on_net_status " + evt.info.code);

      if (net_group != null) {

      Debug.log('estimated member count ' + net_group.estimatedMemberCount);

      }

      switch(evt.info.code)

      {

      case "NetConnection.Connect.Success":

      on_net_connected(evt);

      break;

       

      case "NetStream.Connect.Success":

      on_stream_connected(evt);

      break;

       

      case "NetGroup.Connect.Success":

      on_group_connected(evt);

      break;

       

      case "NetGroup.Neighbor.Connect":

      on_neighbor_connected(evt);

      break;

       

      case "NetGroup.Posting.Notify":

      on_posting_notify(evt.info.message);

      break;

       

      case "NetGroup.MulticastStream.PublishNotify":

      on_publish_notify(evt);

      break;

       

      case "NetGroup.Neighbor.Disconnect":

      this.dispatchEvent(new P2PEvent(P2PEvent.NEIGHBOR_DISCONNECTED, evt.info));

      break;

       

      }

      }

       

      private function on_net_connected(evt:NetStatusEvent = null):void

      {

      group_spec = new GroupSpecifier(group_name);

      group_spec.multicastEnabled = true;

      group_spec.serverChannelEnabled = true;

      group_spec.postingEnabled = true;

       

      //Debug.log ("group id: " + group_spec.groupspecWithAuthorizations());

       

      net_stream = new NetStream(net_connection, group_spec.groupspecWithAuthorizations());

      net_stream.multicastWindowDuration = .2;

      net_stream.addEventListener(NetStatusEvent.NET_STATUS, on_net_status);

       

      net_group = new NetGroup(net_connection, group_spec.groupspecWithAuthorizations());

      net_group.addEventListener(NetStatusEvent.NET_STATUS, on_net_status);

       

      this.dispatchEvent(new P2PEvent(P2PEvent.NET_CONNECTED, evt.info));

      }

       

      private function on_stream_connected(evt:NetStatusEvent = null):void

      {

      Debug.warning ("on_net_stream_connected");

      net_stream.client = this;

      this.dispatchEvent(new P2PEvent(P2PEvent.STREAM_CONNECTED));

       

      }

       

      private function on_neighbor_connected(evt:Event = null):void

      {

       

       

      ready();

       

      }

       

      public function ready(evt:Event = null):void

      {

       

      Debug.warning('ready, am i primary? ' + this.primary);

      post_system_message({ stream_id:GaberrModel.getInstance().stream_id,

      status:'ready',

      primary:this.primary,

      topic:GaberrModel.getInstance().room.topic,

      prejudice:GaberrModel.getInstance().user.prejudice

      });

       

       

       

      }

       

      public function cam_activity(evt:Event = null):void

      {

      //Debug.log('cam acitivty');

      //post_system_message({stream_id:GaberrModel.getInstance().stream_id,status:'ready'});

      }

       

      private function on_posting_notify(message:Object):void

      {

       

      //Debug.log ("on_posting_notify " + message);

      Debug.object(message);

      // if this node is being pinged then setup the incomming stream as well

       

      Debug.log('system ' + (message.system == 'system'));

      Debug.log('status ' + (message.status == 'ready'));

       

      if (message.user == 'system') {

       

      this.incomming_stream_name = message.stream_id;

      this.dispatchEvent(new P2PEvent(P2PEvent.SYSTEM_POST, message));

      //setup_incomming_stream();

       

      if (message.status == 'ready') {

      Debug.error('ready::Dispatching neighbor connected');

      this.dispatchEvent(new P2PEvent(P2PEvent.NEIGHBOR_CONNECTED));

      }

       

      } else {

       

      this.dispatchEvent(new P2PEvent(P2PEvent.GROUP_POST, message));

       

      }

      /*

      this.system_data = evt.info.message;

      Debug.warning('system message recieved');

      Debug.object(system_data);

       

      if (!this.primary) {

      // post return handshake

      //post_system_message(system_data);

      }

       

      // setup stream from primary user

      //this.incomming_stream_name = system_data.streams[1];

      //Debug.log('incomming_stream_name ' + incomming_stream_name);

      //setup_incomming_stream();

       

      this.dispatchEvent(new P2PEvent(P2PEvent.NEIGHBOR_CONNECTED, evt.info));

       

      } else {

      this.dispatchEvent(new P2PEvent(P2PEvent.GROUP_POST, evt.info));

      }*/

      }

       

      private function on_publish_notify(evt:NetStatusEvent = null):void

      {

      //Debug.warning('publish notify???');

      this.incomming_stream_name = evt.info.name;

       

      setup_incomming_stream();

      }

       

       

      private function setup_incomming_stream(evt:NetStatusEvent = null):void

      {

       

      Debug.log('setup_incomming_stream ');

      net_connection.removeEventListener(NetStatusEvent.NET_STATUS, on_net_status);

      net_connection.addEventListener(NetStatusEvent.NET_STATUS, on_incomming_net_status);

      //incomming_stream = new NetStream(net_connection, NetStream.DIRECT_CONNECTIONS);

      incomming_stream = new NetStream(net_connection, group_spec.groupspecWithAuthorizations());

      incomming_stream.addEventListener(NetStatusEvent.NET_STATUS, on_incomming_net_status);

      incomming_stream.client = this;

       

       

      }

       

      private function on_incomming_net_status(evt:NetStatusEvent):void {

       

      Debug.log ("on_incomming_net_status " + evt.info.code);

      Debug.object(evt.info);

      switch(evt.info.code)

      {

      case "NetConnection.Connect.Success":

      Debug.log ("net_connection connected");

      //on_incomming_net_connected();

      break;

      case "NetStream.Connect.Success":

      on_incomming_stream_connected();

      break;

      }

      }

       

       

      private function on_incomming_stream_connected():void

      {

      // load other stream

      Debug.log ("on_incomming_stream_connected, creating video player");

      incomming_stream.client = this;

      this.dispatchEvent(new P2PEvent(P2PEvent.INCOMMING_STREAM_CONNECTED));

       

      }

       

       

      public function post_message(username:String, val:String):void {

       

      var mes:Object = {};

      mes.user = username;

      mes.text = val;

      mes.sequence = seq_num++;

      mes.sender = net_connection.nearID;

       

      var status:String = net_group.post(mes);

      Debug.log('post status ' + status);

       

      }

       

      public function post_system_message(mes:Object):void {

       

      mes.user = 'system';

      mes.sequence = seq_num++;

      mes.sender = net_connection.nearID;

       

      var status:String = net_group.post(mes);

      Debug.log('post status ' + status);

       

      }

       

      private function on_group_connected(evt:NetStatusEvent = null):void

      {

       

      Debug.log ("joined group! " + group_name);

      this.dispatchEvent(new P2PEvent(P2PEvent.GROUP_CONNECTED, group_name));

       

      Debug.log('estimated member count ' + net_group.estimatedMemberCount);

       

      }