我正在尝试更改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 {}");
}
}