20090220-20090221 (Red5 Study 1)

本文详细介绍了Red5服务器的核心组件及工作原理,包括IScope、ApplicationAdapter、IConnection等关键对象的功能与交互方式。探讨了资源访问、客户端连接管理、数据同步及持久化的实现机制。

IScope: A statefull object shared between a group of clients connected to the same context path. Scopes are arranged in hierarchical way, so its possible for a scope to have a parent and children scopes.If a client connects to a scope then they are also connected to its parent scope. The scope object is used to access resources, shared object, streams, etc. That is, scope are general option for grouping things in application. The following are all names for scopes: application, room, place, lobby.


ApplicationAdapter: The app* methods are called for the main application, the room* methods are called for
rooms (i.e. instances) of the application. (subsequentail call will only trigger connect, not join, so join is bigger)
Assuming you connect to rtmp://server/app/room1/room2
First connection:
1. app (-> appConnect)
2. room1 (-> roomConnect)
3. room2 (-> roomConnect)
After first connection:
1. app (-> appJoin)
2. room1 (-> roomJoin)
3. room2 (-> roomJoin)
matrix start/stop connect/disconnection join/leave
app ...  ...   ...
room ...  ...   ...
For start/connection/join, return true if success, false otherwise.
rejectClient methods can be called to reject a currently connecting client, different between start/connection/join return false?


IConnection: Each connection has an associated client and scope.
Current connection is retrieved through: 1. Red5.getConnectionLocal(); 2. when "public XXX xxx(IConnection conn, ...)" is called by client.


Client call server's methods: (methods inside application adapter is automatically callable from client?) Register an object (can be any type) as a handler using the following 2 ways:
1.<bean id="sample.service" class="com.fancycode.red5.HandlerSample" singleton="true" />
Note that "service" is a keyword, client codes only need to refer to "sample". This will apply to all scope.
2.Iscope(IServiceHandlerProvider).registerServiceHandler("sample", handler), note that this will override the spring config for chosen scope, and should  consider putting it in either appStart/roomStart to choose correct scope.


Server call client's methods: if IConnection is IServiceCapableConnection, use the invoke method, pass a IPendingServiceCallback if you need a method call result.


ISharedObject:
Create/retrieve: use ApplicationAdapter.createSharedObject/getSharedObject. Create it in appStart/Connect or roomStart/Connect.
Data synchronization: use ISharedObject.setAttribute to update data, use ISharedObject.beginUpdate/endUpdate to issue a batch update, use ISharedObject.addSharedObjectListener(ISharedObjectListener) to get informed by update.
Method call: use ISharedObject.registerServiceHandler or <bean id="sampleSO.one.two.soservice" class="com.fancycode.red5.MySharedObjectHandler" /> ("soservice" is keyword, and the shared object will be created in all scope?) to register a service, use ISharedObject.sendMessage to invoke service.


Persistence:
IPersistable: Basically these objects have a type, a path, a name (all strings) and know how to serialize and deserialize themselves.
IPersistenceStore: Used to save and load IPersistable to somewhere. For FilePersistence implementation, a file is created in "webapps/<app>/persistence/<type>/<path>/<name>.red5", e.g. for a shared object "theSO" in the connection to "rtmp://server/myApp/room1" a file at
"webapps/myApp/persistence/SharedObject/room1/theSO.red5" would be created.
To make a object persitable, either put it in IScope through IAttributeStore's method, because IScope implements IPersistable, it will be load/save by server automatically, or find the global IPersistenceStore used by the server, using IScope.getStore(), to load/save object manually.


Scheduling: includes ISchedulingService and IScheduledJob, as ApplicationAdapter already implements ISchedulingService, all you have to do is just implement IScheduledJob, add it to ApplicationAdapter and store the job id somewhere (in a IScope maybe) so that you can manage it from ApplicationAdapter later.


Stream file name:
IStreamFilenameGenerator: implement this class to decide the file path to save in server, use <bean id="streamFilenameGenerator" class="..." /> (use IStreamFilenameGenerator.BEAN_NAME as bean id).
Flash client: the NetStream.play/publish method accept a file name, which will be used to resolve to actual path in server.

 

 


Compare ApplicationAdapter with Servlet?


ApplicationAdapter/IConnection/IXXXHandler design pattern?

【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较不同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值