Red5支持Remoting,但一直没有试过,最近在项目中要用到,于是研究了下。
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IScope;
import org.red5.server.net.remoting.RemotingClient;
import org.red5.server.net.remoting.IRemotingCallback;
//实现IRemotingCallback,处理返回信息
public class Application extends ApplicationAdapter implements IRemotingCallback{
public IScope app;
public Log log = LogFactory.getLog(Application.class);
private RemotingClient _service;
@Override
public boolean appStart(IScope app){
this.app = app;
//Remoting的网关地址
String gateway = "http://192.168.0.180/amfphp/gateway.php";
//定义一个RemotingClient对象
_service = new RemotingClient(gateway);
//调用服务器上HelloWorld对象的的函数
_service.invokeMethod("HelloWorld.hello",new Object[]{"red5"},this);
return true;
}
public void errorReceived(RemotingClient client, String method, Object[] params, Throwable error){
//An error occured while performing the remoting call.
log.debug("error:"+error);
error.printStackTrace();
}
public void resultReceived(RemotingClient client, String method, Object[] params, Object result) {
//
log.debug("method:"+method+" params: "+params+" result:"+result);
}
}
反复实验了几次,AMFPHP可以接收到red5服务器端的数据,但red5却总收不到AMFPHP的返回数据?
不知道是不是不支持amf3的原因?有待进一步研究
另外,我的Blog已搬家,新的地址是www.fluidea