Skip navigation
Currently Being Moderated

Find out the connection lost

Sep 5, 2011 2:48 AM

I have done the application with two type of authentication

 

First one is the presenter

Second one is the viewer

(both are connect to the same FMS application)

 

i want to notify the viewer when presenter log out or connection lost , how it's possible, please help me, thanks in advance

 
Replies
  • Currently Being Moderated
    Sep 5, 2011 5:43 AM   in reply to Thirumalaimurugan

    NetStatus event listener. Its in the AS3.0 live docs.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2011 5:51 AM   in reply to Thirumalaimurugan

    You'll need to keep track of the two clients on the server side, and invoke a client side method on the viewer client when the presenter disconnects. For example:

     

    On the viewer, you'll have a method in the netconnection's client object:

     

    onPresenterDisconnect = function(){

    // Notify the client here

    }

     

    on the server side:

     

    application.onDisconnect = function(client){

    // Test to see if the disconnecting client is the presenter

    if(client is the presenter){

    // Loop through the client list to find the viewer or viewers

    for(var i=0; i<application.clients.length; i++){

    if(application.clients[i] is a viewer){

    application.clients[i].call("onPresenterDisconnect" null);

    }

     

    }

     

    Obvoiously, the above is not complete code. You'll need to add your own logic to determine whether a given client is a presenter or a viewer.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2011 7:11 AM   in reply to JayCharles

    oh yeah I was a little hasty on this one sorry. I would probably have an object on the server side that tracks all users and have an attribute that denotes presenter or subscriber. something like

     

    //intialize in onAppStart

    this.adminObj = new Object();

     

     

    //get user data from connection string on client side

    "rtmp://192.168.1.102/someApp/someInstance","userNameVariable"

     

    //add username in onConnect to Object

    client.userName=userName;
    this.userObj[client.userName]=client;

     

     

    //call this from client side depending on whether the user chooses to be presenter or subscriber.

    Client.prototype.setStreamID = function(userName,streamType){

     

    this.userObj[client.userName].streamID = streamType;

    }

     

    //find out onDisconnect what type the client is.

    //application.onDisconnect = function(oldClient)

    if(application.userObj[oldClient.userName].streamID=="presenter"){
      //then either send or call the subscribers
      }

     

    //This is imperfect just an example of how I might go about it.........I've also have tracke FPS on the client side to see when the presenter stops presenting. to track frames per second though you need to continously poll the fps property of the netstream with either a timer or onEnter (onEnterFrame).

     
    |
    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