Skip navigation
Currently Being Moderated

can't receive any Netgroup event

May 21, 2012 2:58 AM

Tags: #netgroups

hello, I am using Netgroups with FMS(rtmfp). I can connect to the Netgroup (reiceve NetStatusEvent "NetGroup.Connect.Success") but that is all. I can't post anything or see that someone has joined the Netgroup, no NetStatusEvent fires. What am I missing?

 

 

_groupSpecifier = new GroupSpecifier(test_group); 
_groupSpecifier.postingEnabled = true; 
_groupSpecifier.multicastEnabled = true;             
_groupSpecifier.serverChannelEnabled = true; 

_netGroup = new NetGroup(_nc, _groupSpecifier.groupspecWithAuthorizations()); 
_netGroup.addEventListener(NetStatusEvent.NET_STATUS, groupNetStatusHandler);    
 
Replies
  • Currently Being Moderated
    May 21, 2012 5:52 AM   in reply to perconte2121

    Hi,

     

    Can you post the full code as from the above code it's not clear what are you trying to do. If you don't want to post the full code then you can send me that as private message.

     
    |
    Mark as:
  • Currently Being Moderated
    May 21, 2012 7:17 AM   in reply to perconte2121

    Before calling the post() method, you should check for the NetGroup.Neighbor.Connect event. Once this event is received then you can call the post() method. So, try creating one more client and connect to the same GroupSpecifier. And after the above mentioned event is received, call the post() method.

     
    |
    Mark as:
  • Currently Being Moderated
    May 21, 2012 11:29 PM   in reply to perconte2121

    You don't have to implement any server side code. Just keep a blank app on the server and make two client side apps.

    In the first client side app, add the following case.

     

         case "NetGroup.Neighbor.Connect":                   
               
    //!!! post msg to the group, no one receives this message
               
    var message:Object = new Object;                   
                message
    .text = "Hello";                
                message
    .sender = _nc.nearID;                   
                _netGroup
    .post(message);
               
    break;

    Don't put above code under - case "NetGroup.Connect.Success"

     

     

    In the 2nd client side app, keep everything same as the 1st client. Just comment out the above mentioned code under case "NetGroup.Neighbor.Connect".

     

    After this, 1st run the 1st client and then the 2nd client, you'll receive both the events:"NetGroup.Neighbor.Connect" and "NetGroup.Posting.Notify".

     

     
    |
    Mark as:
  • Currently Being Moderated
    May 22, 2012 1:28 AM   in reply to perconte2121

    //1st client as file (TestPost.as)

     

    package  {
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.net.GroupSpecifier;
    import flash.net.NetGroup;

     

    public class TestPost extends Sprite {
      var _nc:NetConnection;
      var _groupSpecifier:GroupSpecifier;
      var _netGroup:NetGroup;
     
      public function TestPost() {
       // constructor code
       connect("rtmfp://serverIP/app_name");
      }
     
      public function connect(url:String):void {                 
       _nc = new NetConnection();
       _nc.client = this;
       _nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
     
       _nc.connect(url);  
      }
     
      private function netStatusHandler(event:NetStatusEvent):void {
       trace("NetStatusEvent : "+event.info.code);
       switch (event.info.code){
        case "NetConnection.Connect.Success":              
         createGroup();
         break; 
        case "NetGroup.Connect.Success":                   
         break;
       
        case "NetGroup.Neighbor.Connect":                   
         //!!! post msg to the group, no one receives this message
         var message:Object = new Object;                   
         message.text = "Hello";                
         message.sender = _nc.nearID;   


      
         _netGroup.post(message);
         break;
        default:                   
         trace("event.info.code: " + event.info.code);          
         break;
       }              
      }
     
      private function createGroup():void {
       _groupSpecifier = new GroupSpecifier("test_group");
       _groupSpecifier.postingEnabled = true;
       _groupSpecifier.multicastEnabled = true;           
       _groupSpecifier.serverChannelEnabled = true;
     
       _netGroup = new NetGroup(_nc, _groupSpecifier.groupspecWithAuthorizations());
       _netGroup.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);       
      }  


    }

     

    }

     

     

    //2nd client as file(TestPost_1.as)

     

    package  {
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.net.GroupSpecifier;
    import flash.net.NetGroup;

     

    public class TestPost_1 extends Sprite {
      var _nc:NetConnection;
      var _groupSpecifier:GroupSpecifier;
      var _netGroup:NetGroup;
     
      public function TestPost_1() {
       // constructor code
       connect("rtmfp://serverIP/app_name");

      }
     
      public function connect(url:String):void {                 
       _nc = new NetConnection();
       _nc.client = this;
       _nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
     
       _nc.connect(url);  
      }
     
      private function netStatusHandler(event:NetStatusEvent):void {
       trace("NetStatusEvent : "+event.info.code);
       switch (event.info.code){
        case "NetConnection.Connect.Success":              
         createGroup();
         break;             
        case "NetGroup.Connect.Success":                   
         //!!! post msg to the group, no one receives this message
         /*var message:Object = new Object;                   
         message.text = "Hello";                
         message.sender = _nc.nearID;   

     

     

         _netGroup.post(message);
         break;*/
        default:                   
         trace("event.info.code: " + event.info.code);          
         break;
       }              
      }
     
      private function createGroup():void {
       _groupSpecifier = new GroupSpecifier("test_group");
       _groupSpecifier.postingEnabled = true;
       _groupSpecifier.multicastEnabled = true;           
       _groupSpecifier.serverChannelEnabled = true;
     
       _netGroup = new NetGroup(_nc, _groupSpecifier.groupspecWithAuthorizations());
       _netGroup.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);       
      }  


    }

     

    }

     

    First run the 1st client and then run the 2nd client. I have tried at my end and it's working.

     
    |
    Mark as:
  • Currently Being Moderated
    May 22, 2012 3:16 AM   in reply to perconte2121

    Can you try it on FMS 4.5.2 and see if it's working for you?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points