本文介绍了如何使用Red5 API识别发布者和消费者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public boolean connect(IConnection conn, IScope scope, Object[] params)
{
IClient client = conn.getClient();
log.info( "app connect " + conn.getClient().getId() );
client.setAttribute( "stamp", new Long( 0 ) );
return true;
}
这是每次客户端在Red5 Server中的我的自定义应用程序上连接时都会调用的方法,因此有一种方法可以识别客户端是在我的服务器上流式传输的订户(消费者,查看者)还是发布者(用户) ).
This is the method which is being called every time Client is connected at my Custom Application in Red5 Server ,so is there a way to identify if a Client is Subscriber (Consumer ,Viewer) or Publisher (User which streams at my server).
最佳
推荐答案
要禁止或允许发布或订阅用户,可以在appStart回调方法中使用这些方法:
To disallow or allow publish or subscribe a user, you can use those methods inside appStart callback method:
- registerStreamPlaybackSecurity
- registerStreamPublishSecurity
有关更多信息,请查看:
For more, look to the:
http://dl.fancycode.com/red5/api/org/red5/server/adapter/MultiThreadedApplicationAdapter.html
我正在使用jRuby,这很容易做到:
I'm using jRuby, and it's very easy to do so:
registerStreamPlaybackSecurity do |scope, name, start, len, flush|
false # no playback allowed
end
registerStreamPublishSecurity do |scope, name, mode|
rand(1) % 1 == 0 # publishing (recording) sometimes allowed, sometimes no
end
这篇关于如何使用Red5 API识别发布者和消费者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!