[Red5] IScheduledJob

Mamontov Sergey V. moonlight at ua.elro.com
Tue Nov 27 12:10:13 PST 2007


Hello Art,

You can use next code to invoke Schedulere wherever you wan :)

ISchedulingService scheduler = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
String jobName = scheduler.addScheduledJob(int millisecondTime, new IScheduledJob() {
   public void execute(ISchedulingService service) {
     //any actions
   }
   });

Also, you can make own class witch will implements  IScheduledJob and have method execute(), and the code will be smaller:

ISchedulingService scheduler = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
String jobName = scheduler.addScheduledJob(int millisecondTime, new Job());


class Job implements IScheduledJob{
   public void execute(ISchedulingService service) {
     // any actions
   }
}


You also maybe will be needed in sending connection information to the scheduler. For this case you can make constructor for your class (Job):

ISchedulingService scheduler = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
String jobName = scheduler.addScheduledJob(int millisecondTime, new Job(Red5.getConnectionLocal()));


class Job implements IScheduledJob{

   private IConnection conn;

   public void Job (IConnection appConnection){
      conn = appConnection;
   }

   public void execute(ISchedulingService service) {
     // any actions
   }
}


Regards,

Sergey

>     
>   
>   
> Hi folks,
>   
>  
>   
> Stupid question #2: Any recommendations on how to set up a
> IScheduledJob in a Red5 service (i.e. not an ApplicationAdapter)? 
>   
>  
>   
> What I’m trying to do is set up a job that runs every second,
> checks all events my service has generated, and then sends them off
> to any flash clients who had previously indicated interest.
>   
>  
>   
> My Red5 service class doesn’t have access (as far as I can tell) to
> the ApplicationAdapter object, and so I can’t grab it’s
> implementation of ISchedulingService to use (for example:
>   
>  
>   
> app.addScheduledJob(1000, myIScheduledJobObject);
>   
>  
>   
> )
>   
>  
>   
> I’d rather not implement my own scheduling… I’m sure there is a
> simple either Red5 or Spring method that I just don’t know.
>   
>  
>   
> Thanks in advance,
>   
>  
>   
> - Art
>   
>  
>   
>   
>     


-- 
С уважением,
 Mamontov                          mailto:moonlight at ua.elro.com




More information about the Red5 mailing list