3 Replies Latest reply on Sep 16, 2014 1:24 PM by Michael Thornburgh

    NetGroup problems connecting devices with different internet connection

    AndreyE

      Create a chat using technology Cirrus (p2p) and class NetGroup.

       

      If the device is a mobile phone, and has network via 3G or 4G, then connect to the same group with other devices is not happening.

       

      For example, there are a PC and the mobile device:

      1 If both are connected to one Wi-Fi:

      onNetConnectionNetStatus: NetConnection.Connect.Success

      onNetConnectionNetStatus: NetGroup.Connect.Success

      onNetGroupNetStatus: NetGroup.Neighbor.Connect

      A connection is made.

       

      2 If both are connected to different Wi-Fi:

      onNetConnectionNetStatus: NetConnection.Connect.Success

      onNetConnectionNetStatus: NetGroup.Connect.Success

      onNetGroupNetStatus: NetGroup.Neighbor.Connect

      A connection is made.

       

      3.If one device is connected to Wi-Fi, and the other to a 3G or G4

      onNetConnectionNetStatus: NetConnection.Connect.Success

      onNetConnectionNetStatus: NetGroup.Connect.Success

      No connection.

       

      Sample code that was tested:

       

      package {

       

      import flash.display.Sprite;

      import flash.events.NetStatusEvent;

      import flash.net.GroupSpecifier;

      import flash.net.NetConnection;

      import flash.net.NetGroup;

      import flash.text.TextField;

       

      public class NetGroupSample extends Sprite {

         private static const CIRRUS_URL:String = "rtmfp://p2p.rtmfp.net";

         private static const CIRRUS_DEVELOPER_KEY:String = "************************";

       

         private var _netConnection:NetConnection;

         private var _netGroup:NetGroup;

         private var _outputTextField:TextField;

       

         public function NetGroupSample() {

        _outputTextField = new TextField();

        _outputTextField.width = this.stage.stageWidth;

        _outputTextField.height = this.stage.stageHeight;

         this.addChild(_outputTextField);

       

        _netConnection = new NetConnection();

        _netConnection.addEventListener(NetStatusEvent.NET_STATUS, this.onNetConnectionNetStatus);

        _netConnection.connect(CIRRUS_URL, CIRRUS_DEVELOPER_KEY);

         }

       

         private function onNetConnectionNetStatus(event:NetStatusEvent):void {

         this.traceToOutput("onNetConnectionNetStatus:", event.info.code);

         switch (event.info.code) {

         case "NetConnection.Connect.Success":

         var gspec:GroupSpecifier = new GroupSpecifier("Group1");

        gspec.multicastEnabled = true;

        gspec.postingEnabled = true;

        gspec.serverChannelEnabled = true;

        gspec.objectReplicationEnabled = true;

        gspec.routingEnabled = true;

       

        _netGroup = new NetGroup(_netConnection, gspec.groupspecWithAuthorizations());

        _netGroup.addEventListener(NetStatusEvent.NET_STATUS, this.onNetGroupNetStatus);

        break;

         }

         }

       

         private function onNetGroupNetStatus(event:NetStatusEvent):void {

         this.traceToOutput("onNetGroupNetStatus:", event.info.code);

         }

       

         private function traceToOutput(...strings):void {

        _outputTextField.appendText(strings.join(" ") + "\n");

         }

      }

      }

       

      Tested on Adobe AIR SDK 3.2, 3.4, 13.0.0.111