RED5的API介绍-2

org.red5.server.api.scheduling
这是一个需要被实作的介面,我们可以实作此一介面,
并在此撰写每隔一段时间要自动执行的程式码。
在此package下有两个class,
IScheduledJob与ISchedulingService
以下是的一个实作IScheduledJob的范例程式
import org.red5.server.api.scheduling.IScheduledJob;
import org.red5.server.api.scheduling.ISchedulingService;
class MyJob implements IScheduledJob {
private Application app;
public MyJob(Application app) {
   this.app = app;
}
public void execute(ISchedulingService service)
   throws CloneNotSupportedException {
   // 在此写入要做的事
}
}
execute是IScheduledJob内要被我们实作的method
每隔一段时间,Server会自动执行execute这个函数
其传入的参数為一ISchedulingService型态的值
另外我们需要在此app被啟始时,新增这个排程
在实作ApplicationAdapter的appStart method裡新增下面两行
IScheduledJob job = new MyJob(this);
jobId = this.addScheduledJob(5000, job);
在appStop裡新增
this.removeScheduledJob(jobId);
IScheduledJob的相关说明请见
http://dl.fancycode.com/red5/api/org/red5/server/api/scheduling/IScheduledJob.html
ISchedulingService的相关说明请见
http://dl.fancycode.com/red5/api/org/red5/server/api/scheduling/ISchedulingService.html
(责任编辑:温莎)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值