[Red5] Red5.getConnectionLocal() from SchedulerJob returns null

Mamontov Sergey V. moonlight at ua.elro.com
Mon Nov 19 12:02:42 PST 2007


Hi Kyoung,

Thanks for example, but i still can't make it work well :(
This is my code for ScheduledJob:

class myJob30sec implements IScheduledJob{
	
	private Streamer application;
	private IScope cscope;
	private static final Log log = LogFactory.getLog(myJob30sec.class);
	
	public myJob30sec(Streamer app, IScope scope){
		cscope = scope;
		application = app;
	}
	
	public void execute(ISchedulingService service) throws
		CloneNotSupportedException {
		Iterator<IConnection> iter = application.getConnectionsIter();
		while (iter.hasNext()) {
			IConnection conn = iter.next();
			if (conn.getScope().equals(cscope))
			{
				IStreamService pservice = (IStreamService) conn.getScope().getContext().getBean(IStreamService.BEAN_NAME);
				log.info("@_scheduler_@ service name "+pservice);
				pservice.seek(80000);
			}
			log.info("hi connection"); 
		}
	}
}


When I start job, I pass to it my  main application named "Streamer", and scope of current user ( they can be many ).

In result I need to make some action with stream, which is currently playing for selected user, for example seek forward on 80 seconds.

When I trying do something like this in myJob30sec: 
Streamer app = (Streamer)service;
the error appear, that: 
Job com.ppfm.myJob30sec at 14c0275 execution failed: org.red5.server.scheduling.QuartzSchedulingService cannot be cast to com.ppfm.Streamer

If it possible, someone help me, or soon I will be punished.


Regards,


Sergey  



>   
>  hi John
>   
>  you can access Application via IScheduleJob interface,
>  but except a few method of StreamService, i think you can not
> access Appilcation via IStreamService
>   
>  next code is works
>  test it and find your answer
>   
>  public class DummyScheduleJob implements IScheduledJob {
>  private static final Log log = LogFactory.getLog(Application.class);
>  public void execute(ISchedulingService service)
>    throws CloneNotSupportedException {
>   // TODO Auto-generated method stub
>   log.info("dummy schedule joing executed");
>   Application app = (Application)service;
>   Iterator<IConnection> iter = app.getConnectionsIter();
>         while (iter.hasNext()) {
>             IConnection conn = iter.next();
>             log.info("hi connection"); 
>         }
>  }
>  }
>  

>  
>  
>  

>  Date: Sun, 18 Nov 2007 12:35:34 +0200
> From: moonlight at ua.elro.com
> To: red5 at osflash.org
> Subject: Re: [Red5] Red5.getConnectionLocal() from SchedulerJob returns null

>  

>   John,
>  

>  Hello :) 
>  I still don't understand how to make custom events in application.
> And after I found attribute with of corresponding JobName, how can I
> invoke to pause sever stream exactly for this client?
>  

>  P.S. maybe someone found better solution, maybe native for Red5, this will be great :)
>  

>  Regards,
>  

>  Sergey 
>  

>       >
>   I looked at the title of this email and I did a double take
> because I had a "saved" email that I was going to send later with
> pretty much the Exact title. =) I thought gmail accidently sent my saved email hahaha
>  

>  anyway, I found that the way Red5.getconnectionlocal() works only
> allows the local Thread to the IConnection to have access. Since
> SchedulerJob is a completely separate thread, it does not had access to IConnection.
>  

>  I havent found a good solution for this yet, but for now Im
> setting an attribute to the IClient at appconnect and on the
> execute() method I loop through the client for the matching attribute and do my thing.
>  

>  

>  

>  

>  On Nov 16, 2007 9:22 AM, Mamontov Sergey V. <moonlight at ua.elro.com> wrote:
>  

>  Hi,
>  

>  During me development I've discovered some new strange thing. When I'm
>  trying to add some Scheduler in my application, calling of
>  Red5.getConnectionLocal(); return me "null" as connection, when 
>  calling it from body of ShedulerJob, mean time, same call in main
>  class return me connection info.
>  

>  This is small, but main part of class, witch causing strange behavior.
>  

>  public class CustomStreamService extends StreamService implements IScheduledJob { 
>  

>    public void play (String name){
>  

>       IConnection conn = Red5.getConnectionLocal();
>       ISchedulingService service = (ISchedulingService)
> conn.getScope().getContext().getBean(ISchedulingService.BEAN_NAME );
>       ClientData client =
> ((ClientData)conn.getClient().getAttribute("client"));
>       String clientId = client.getId();
>       log.info("@_StreamService_@  Connection info: "+conn); //<- works 
>       great ("Connection RTMPMinaConnection from XX.XXX.XXX.XXX:1245 to
>       XX.XXX.XXX.XXX (in: 3719, out: 5329) ")
>       startPlayBackWatcher();
>    }
>  

>    public void startPlayBackWatcher(){ 
>  

>       IConnection conn = Red5.getConnectionLocal();
>       ISchedulingService service = (ISchedulingService)
> conn.getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
>       ClientData client =
> ((ClientData)conn.getClient().getAttribute("client")); 
>       String jobName1 = service.addScheduledOnceJob(5000, this);
>    }
>  

>    public void execute(ISchedulingService service) throws
>                 CloneNotSupportedException {
>       IConnection conn = Red5.getConnectionLocal ();
>       pause(true, 15000);
>        log.info("@_StreamService_@  Connection info: "+conn); //<-
>        doesn't work :( ( return "null")
>    }
>  

>    What is wrong in my code? Please, help me :) 
>    P.S. Actually I'm not really good Java developer, Flash is My life
>    :)
>  

>  

>  Regards,
>  

>  Sergey
>  

>  

>  _______________________________________________
>  Red5 mailing list
>  Red5 at osflash.org
>  http://osflash.org/mailman/listinfo/red5_osflash.org
>  

>  

>  

>  

>  -- 
>  ?? ???????????,
>   Mamontov                          mailto:moonlight at ua.elro.com


> Explore the seven wonders of the world Learn more!  




More information about the Red5 mailing list