アプリケーションのソース コードfitcDemo
を Red5 用に変更し、サーバーに接続する前に何らかの方法でユーザー名を認証させようとしていますが、開始方法がわかりません。
つまり、クライアント接続時にどのメソッドが呼び出されるのか、クライアント アプリからユーザー名を取得する方法がわからないということです。
誰かが私を助けることができるように、ソースコードをここに持ってきます。
package org.xyz;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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 org.red5.server.api.service.IPendingServiceCall;
import org.red5.server.api.service.IPendingServiceCallback;
import org.red5.server.api.service.IServiceCapableConnection;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IPlayItem;
import org.red5.server.api.stream.IPlaylistSubscriberStream;
import org.red5.server.api.stream.IStreamAwareScopeHandler;
import org.red5.server.api.stream.ISubscriberStream;
public class Application extends ApplicationAdapter
implements IPendingServiceCallback, IStreamAwareScopeHandler
{
protected static Log log = LogFactory.getLog(Application.class);
public boolean appStart(IScope scope)
{
return true;
}
public boolean appConnect(IConnection conn, Object[] params)
{
IServiceCapableConnection service = (IServiceCapableConnection)conn;
log.info("Client connected {} conn {}");
service.invoke("setId", new Object[] { conn.getClient().getId() }, this);
return true;
}
public boolean appJoin(IClient client, IScope scope)
{
log.info("Client joined app {}");
IConnection conn = Red5.getConnectionLocal();
return true;
}
public void streamPublishStart(IBroadcastStream stream)
{
if (log.isDebugEnabled()) {
log.debug("stream broadcast start: {}");
}
IConnection current = Red5.getConnectionLocal();
for (Set<IConnection> connections : this.scope.getConnections())
for (IConnection conn : connections) {
if (conn.equals(current))
{
continue;
}
if ((conn instanceof IServiceCapableConnection)) {
((IServiceCapableConnection)conn).invoke("newStream", new Object[] { stream.getPublishedName() }, this);
if (log.isDebugEnabled())
log.debug("sending notification to {}");
}
}
}
public void streamRecordStart(IBroadcastStream stream)
{
}
public void streamBroadcastClose(IBroadcastStream stream)
{
}
public void streamBroadcastStart(IBroadcastStream stream)
{
}
public void streamPlaylistItemPlay(IPlaylistSubscriberStream stream, IPlayItem item, boolean isLive)
{
}
public void streamPlaylistItemStop(IPlaylistSubscriberStream stream, IPlayItem item)
{
}
public void streamPlaylistVODItemPause(IPlaylistSubscriberStream stream, IPlayItem item, int position)
{
}
public void streamPlaylistVODItemResume(IPlaylistSubscriberStream stream, IPlayItem item, int position)
{
}
public void streamPlaylistVODItemSeek(IPlaylistSubscriberStream stream, IPlayItem item, int position)
{
}
public void streamSubscriberClose(ISubscriberStream stream)
{
}
public void streamSubscriberStart(ISubscriberStream stream)
{
}
public List<String> getStreams()
{
IConnection conn = Red5.getConnectionLocal();
return getBroadcastStreamNames(conn.getScope());
}
public void resultReceived(IPendingServiceCall call)
{
log.info("Received result {} for {}");
}
}