RED 5クライアントの遍歴およびオンラインリストの生成
2233 ワード
詳細
オンラインリスト形式は:接続ID 1、接続ユーザー名1;接続ID 2、接続ユーザ名2;...
オンラインリスト形式は:接続ID 1、接続ユーザー名1;接続ID 2、接続ユーザ名2;...
/*
*
* D5Power Studio [www.d5power.com]
* Code:D5.Benmouse
*
*/
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import java.util.*;
public class Application extends ApplicationAdapter {
private IScope appScope;
private String username="";
// IScope
//appStart , FMS onAppStart
public boolean appStart(IScope app) {
appScope = app;
return true;
}
// , username, FMS onConnect
public boolean appConnect(IConnection conn, Object[] params)
{
username=(String)params[0];
return true;
}
// , username
public boolean appJoin(IClient client, IScope app)
{
client.setAttribute("username",username);
return true;
}
// ,
public String login()
{
IConnection current = Red5.getConnectionLocal();
System.out.println("return getOnlineList();
}
// , , 。
public String getOnlineList()
{
Iterator it=appScope.getConnections();
String onLineList="";
while(it.hasNext())
{
IConnection this_conn=it.next();
IClient ic=this_conn.getClient();
String u=ic.getAttribute("username").toString();
onLineList+=ic.getId()+","+u+";";
System.out.println(u);
}
System.out.println("--->");
return onLineList;
}
public boolean sendMSG()
{
//IScope scope = conn.getScope();
Iterator it = appScope.getConnections();
String i="";
while(it.hasNext())
{
IConnection this_conn=it.next();
i+=this_conn.getClient().getAttribute("username")+",";
}
return true;
}
}