从下载的red5的webapps中,复制一份SOSample,将其命名为mychat,
修改相应的配置文件,第一个要修改的是red5-web.properties,将其中的
webapp.contextPath=/xxx
?
修改为
webapp.contextPath=/mychat
?第二步修改red5-web.xml,将其中的
<bean id="web.handler"
class="org.red5.server.adapter.ApplicationAdapter"
singleton="true" />
class="org.red5.server.adapter.ApplicationAdapter"
singleton="true" />
?
修改为:
<bean id="web.handler"
class="org.d5.first.Application"
singleton="true" />
class="org.d5.first.Application"
singleton="true" />
?第三步修改web.xml,将如下数据进行修改
<display-name>SOSample</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>/SOSample</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>/SOSample</param-value>
</context-param>
?修改为:
<display-name>mychat</display-name>
<context-param>
? <param-name>webAppRootKey</param-name>
?? <param-value>/video</param-value>
</context-param>
<context-param>
? <param-name>webAppRootKey</param-name>
?? <param-value>/video</param-value>
</context-param>
?
第四步,新建类,该类要继承ApplicationAdapter这个基础类,代码如下
package org.d5.first; import org.red5.server.adapter.ApplicationAdapter; public class Application extends ApplicationAdapter { public String login(){ System.out.println("welcome to the chat room "); return "Welcome to Chat Servers"; } }
?编译后写放到red5的webapps/mychat/WEB-INF/lasses下,下面写测试,flex As项目
package { import flash.display.Sprite; import flash.events.NetStatusEvent; import flash.net.NetConnection; import flash.net.NetStream; import flash.net.Responder; public class test extends Sprite { private var nc:NetConnection; private var callResponder:Responder = new Responder(getResult); public function getResult(msg:String):void{ trace(msg) } public function test() { nc=new NetConnection(); nc.connect("rtmp://localhost:1935/mychat"); nc.call("login",callResponder); //nc.call("login",nc); } } }
?
测试代码中的端口参考red5的conf/red5.properties.
debug下使用web应用程序没有问题,运行成功。鼓励鼓励吧