欢迎各位兄弟 发布技术文章
这里的技术是共享的
下面是改写的java 源代码
好像上面的也不行 必须要用 java反编译工具才行
原来的文件 (war文件 是从 http://red5.googlecode.com/svn-history/r3990/snapshots/oflaDemo-r3989-java6.war 得来的)
把Application.java 放在eclipse里,如果报错 引入相应的java文件 和jar文件
(主要是jar文件 到red5的服务器下面的lib库中找,引入的jar文件有jcl-over-slf4j-1.5.6.jar,
jul-to-slf4j-1.5.6.jar,log4j-over-slf4j-1.5.6.jar,logback-classic-0.9.14.jar,
logback-core-0.9.14.jar,slf4j-api-1.5.6.jar,tomcat-juli-slf4j-1.5.0.jar
)
red5 中可能用到的源文件 https://github.com/Red5/red5-server-common/tree/master/src
https://github.com/Red5/red5-server/tree/master/src/main/java/org/red5/server/adapter
源文件 jar 文件 最好还是在 red5 下面搜吧
下面是反编译后的源文件
package org.red5.demos.oflaDemo;
import java.io.PrintStream;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.stream.IServerStream;
import org.slf4j.Logger;
public class Application extends ApplicationAdapter
{
private IScope appScope;
private IServerStream serverStream;
private String selfDomain = "http://yc.4000512126.com";
public boolean appStart(IScope app)
{
super.appStart(app);
this.log.info("oflaDemo appStart");
System.out.println("oflaDemo appStart");
this.appScope = app;
return true;
}
public boolean appConnect(IConnection conn, Object[] params)
{
//String firstYunxu = "127.0.0.1";
//String secondYunxu = "118.123.22.204";
//String ip = conn.getRemoteAddress();
//下面的4行代码是加固的,好像是可以不要的
if (!((conn.getConnectParams().get("swfUrl")+"").indexOf(selfDomain)>-1))
{
log.info("this swf Url is "+selfDomain);
return false;
}
if (!((conn.getConnectParams().get("pageUrl")+"").indexOf(selfDomain)>-1))
{
log.info("this domain is "+selfDomain);
return false;
}
else {
this.log.info("oflaDemo appConnect");
return super.appConnect(conn, params);
}
}
public void appDisconnect(IConnection conn)
{
this.log.info("oflaDemo appDisconnect");
if ((this.appScope == conn.getScope()) && (this.serverStream != null)) {
this.serverStream.close();
}
super.appDisconnect(conn);
}
}