12 Replies Latest reply on May 7, 2011 9:04 AM by Nabeel mol

    Peer2Peer Android Adobe Air Not Working !!!!!

    Nabeel mol

      Hello All,

      I tried to create a small app for my mobile ( android 2.2.1 ) to chat, the app is not working here is the code :

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" creationComplete="view1_creationCompleteHandler(event)"
              xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
          <fx:Script>
              <![CDATA[
                  import mx.events.FlexEvent;
                  import flash.net.NetConnection;
                  import flash.net.NetGroup;
                  import flash.net.GroupSpecifier;
                 
                  private var nc:NetConnection;
                  private var group:NetGroup;
                 
                  protected function view1_creationCompleteHandler(event:FlexEvent):void
                  {
                      this.title = "P2P Chat App";
                     
                      NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
                     
                      nc = new NetConnection();
                      nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
                      nc.connect('rtmfp://p2p.rtmfp.net', 'key');
                  }
                 
                  protected function CloseButClick(event:MouseEvent):void
                  {
                      NativeApplication.nativeApplication.exit();
                  }
                 
                  protected function netStatus(event:NetStatusEvent):void
                  {
                      trace(event.info.code);
                      switch(event.info.code)
                      {
                          case "NetConnection.Connect.Success":
                              setupGroup();
                              break;
                          case "NetGroup.Connect.Success":
                              messages.appendText("Room Connected\n");
                              break;
                          case "NetGroup.Neighbor.Connect":
                              messages.appendText("New Client Connected\n");
                              break;
                          case "NetGroup.Posting.Notify":
                              messages.appendText(event.info.message.message + "\n");
                              break;
                      }
                  }
                 
                  private function setupGroup():void
                  {
                      trace(nc.nearID);
                      var groupspec:GroupSpecifier = new GroupSpecifier("myGroup/group0");
                      groupspec.postingEnabled = true;
                      groupspec.ipMulticastMemberUpdatesEnabled = true;
                     
                      group = new NetGroup(nc, groupspec.groupspecWithAuthorizations());
                      group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
                     
                      topGroup.enabled = true;
                  }
                 
                  protected function send_message_clickHandler(event:MouseEvent):void
                  {
                      var message:Object = new Object();
                      message.message = user_message.text;
                      group.sendToAllNeighbors(message);
                      user_message.text = "";
                  }
                 
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <s:layout>
              <s:VerticalLayout gap="5" paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5"/>
          </s:layout>
         
          <s:HGroup width="100%" verticalAlign="middle" enabled="false" id="topGroup">
              <s:TextInput width="100%" id="user_message"/>
              <s:Button label="Send" id="send_message" click="send_message_clickHandler(event)"/>
          </s:HGroup>
         
          <s:TextArea id="messages" width="100%" height="100%" editable="false"/>
         
          <s:Button label="Close" id="close_but" click="CloseButClick(event)"/>
         
      </s:View>

       

      and I visited the cc.rtmfp.net and got all greens except the first one : knows public ip address of self