org.red5.server.api.service.IServiceCapableConnection
我们可以在此撰写此一连线(NetConnection)的侦听状态
下面為一个范例程式:
import java.util.Iterator;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.service.IServiceCapableConnection;
public class Application extends ApplicationAdapter{
public void join(String myName) {
Iterator it = scope.getConnections();
while (it.hasNext()) {
IConnection conn = it.next();
if (conn instanceof IServiceCapableConnection) {
((IServiceCapableConnection) conn).invoke("onNewMemberJoined",
new Object[] { myName });
}
}
}
}
以上的程式会在flash端有人呼叫nc.call("join",nc,"小佳")时,
传送状态和参数给所有正在此一连线上的使用者。
我们可以在flash端加上此一程式码来接收并做出对应的动作
nc.onNewMemberJoined = function(name:String) {
history.text += "欢迎"+name+"加入/n";
};
关於IServiceCapableConnection的介绍可见
http://dl.fancycode.com/red5/api/org/red5/server/api/service/IServiceCapableConnection.html
|
RED5的API介紹-3
最新推荐文章于 2012-08-14 17:23:12 发布