Search code examples
javared5

Red5 - Invoking client methods from application server independantly


How would you invoke a client flash method from application server in java applicationadapter. I know how to invoke client flash methods from application server when adding this to flash client:

        var responseText:Responder = new Responder(GetYourStreamingTicket);

        nc.call("GetYourStreamingTicket",responseText,ui_main.txt_username.text, ui_main.lbl_Category.text);

        private function GetYourStreamingTicket(object:Object)
        {
        var val:int = object as int;
        ui_main.lbl_yst.text = val;
        }

but the above is really sending a request to the server from flash client and the server responding to the request, but how do you make an independent call from java application server to client flash?

Basically i ask this question because i want all the users connected to the server now when i client has disconnected.


Solution

  • CLIENT-SIDE

     var rtmpNow:String="rtmp://192.168.1.2/chatter";
      nc=new NetConnection;
      nc.client = this;
    
      public function DisconnectedUser()
      {
       trace("User Disconnected")
      }
    

    SERVER-SIDE

      public void appLeave(IClient client, IScope app)
      {
        for(Iterator e = users.iterator(); e.hasNext();)
            {
            User user = (User) e.next();
            IConnection conn = user.conn;
            ((IServiceCapableConnection) conn).invoke("DisconnectedUser");  
        }
      }