RED5学习笔记二 :RED5项目配置

RED5学习笔记(二):RED5项目配置

服务器端:

red5的项目的建立与tomact非常的相似.

1、在 Red5的安装路径C:Program FilesRed5webapps下建立自己的项目文件夹:

  2、将C:Program FilesRed5doctemplatesmyapp下的文件夹WEB-INF复制到自己的项目中,WEB-INF里是red5主要的项目配置文件。

3、 在WEB-INF下建立classes以及src文件夹。

4、在项目根目录下建立Eclipes项目。classes为编译目录,src为源码目录。

5、导入red5 jar包。



6、修改配置文件:

web.xml文件



<?xmlversion="1.0"encoding="ISO-8859-1"?>

<web-app

xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version="2.4">

<display-name>MysampleRed5application</display-name>

<context-param>

<param-name>globalScope</param-name>

<param-value>default</param-value>

</context-param>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/red5-*.xml</param-value>

</context-param>

<context-param>

<param-name>locatorFactorySelector</param-name>

<param-value>red5.xml</param-value>

</context-param>

<context-param>

<param-name>parentContextKey</param-name>

<param-value>default.context</param-value>

</context-param>

<!--如果不注释需要导入log4j的jar包。。。。。。。一定小心

<context-param>

<param-name>log4jConfigLocation</param-name>

<param-value>/WEB-INF/log4j.properties</param-value>

</context-param>

-->

<context-param>

<param-name>webAppRootKey</param-name>

<param-value>/chatApp</param-value>

</context-param>

<!--

<listener>

<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>

</listener>

-->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<!--removethefollowingservlettagsifyouwanttodisableremotingforthisapplication-->

<servlet>

<servlet-name>gateway</servlet-name>

<servlet-class>org.red5.server.net.servlet.AMFGatewayServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>gateway</servlet-name>

<url-pattern>/gateway</url-pattern>

</servlet-mapping>

<security-constraint>

<web-resource-collection>

<web-resource-name>Forbidden</web-resource-name>

<url-pattern>/streams/*</url-pattern>

</web-resource-collection>

<auth-constraint/>

</security-constraint>

</web-app>



red5-web.xml



<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<beanid="placeholderConfig">

<propertyname="location"value="/WEB-INF/red5-web.properties"/>

</bean>

<beanid="web.context"

autowire="byType"/>

<beanid="web.scope"

init-method="register">

<propertyname="server"ref="red5.server"/>

<propertyname="parent"ref="global.scope"/>

<propertyname="context"ref="web.context"/>

<propertyname="handler"ref="web.handler"/>

<propertyname="contextPath"value="${webapp.contextPath}"/>

<propertyname="virtualHosts"value="${webapp.virtualHosts}"/>

</bean>

<!-------项目的主类--------->

<beanid="web.handler"



singleton="true"/>

<!--thiswillsupportcallingmethodsthrough"myhandler.<methodName>"-->

<!--

<beanid="myhandler.service"



singleton="true"/>

-->

</beans>



red5-web.properties

webapp.contextPath=/chatApp

webapp.virtualHosts=localhost,127.0.0.1

7、建立程序的入口类

Application.java



packagecom.papaya;

importorg.red5.io.utils.ObjectMap;

importorg.red5.server.adapter.ApplicationAdapter;

importorg.red5.server.api.IScope;

importcom.papaya.VO.MapConventPojo;

importcom.papaya.VO.User;

publicclassApplicationextendsApplicationAdapter

{

publicStringsayHello(Stringname)

{

System.out.println("hello"+name);

return"hello"+name;

}

publicbooleanappStart(IScopescope)

{

System.out.println("聊天服务器启动了!!!!");

returntrue;

}

publicObjectsendVo(ObjectMapmessage)

{

Useruser=newUser();

MapConventPojo.Convent(message,user);

System.out.println(user.getAge());

System.out.println(user.getName());

System.out.println(user.getSchool());

returnuser;

}

}



8、建立客户端flash类



packagecom.renaun.samples.net

{

importcom.game.Logger;

importflash.events.AsyncErrorEvent;

importflash.events.Event;

importflash.events.IEventDispatcher;

importflash.events.IOErrorEvent;

importflash.events.NetStatusEvent;

importflash.events.SecurityErrorEvent;

importflash.net.NetConnection;

importcom.game.Logger;

/**

*Note:ThisclasswasdynamicinActionScript2.0butisnowsealed.

*Towritecallbackmethodsforthisclass,youcaneitherextendthe

*classanddefinethecallbackmethodsinyoursubclass,oryoucan

*usetheclientpropertytorefertoanobjectanddefinethecallback

*methodsonthatobject.

*/

dynamicpublicclassFMSConnectionextendsNetConnectionimplementsIEventDispatcher

{

//--------------------------------------------------------------------------

//

//Constructor

//

//--------------------------------------------------------------------------

publicstaticconstSUSSESS:String="success";

publicstaticconstFAILURE:String="Failure";

/**

*Constructor

*/

publicfunctionFMSConnection()

{

RED5学习笔记(二):RED5项目配置
super();

}

publicvarclientID:Number;

//--------------------------------------------------------------------------

//

//Methods

//

//--------------------------------------------------------------------------

/**

*Connect

*/

overridepublicfunctionconnect(url:String,  args):void

{

//SetobjectencodingtobecompatiblewithFlashMediaServer

this.objectEncoding=flash.net.ObjectEncoding.AMF0;

NetConnection.defaultObjectEncoding

//Addstatus/securitylisteners

this.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);

this.addEventListener(SecurityErrorEvent.SECURITY_ERROR,netSecurityError);

this.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler);

this.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);

//TODOdoesnotpass  argsintothesuperfunction

super.connect(url);

}

/**

*setID

*/

publicfunctionsetId(id:Number):*

{

Logger.debug("FMSConnection::setId:id="+id);

if(isNaN(id))return;

clientID=id;

return"Okay";

}

/**

*StatusHandlerfortheNetConnectionclass

*/

privatefunctionnetStatusHandler(event:NetStatusEvent):void

{

switch(event.info.code){

case"NetConnection.Connect.Success":

Logger.debug("FMSConnection:netStatusHandler:Success:connected:"+this.connected);

dispatchEvent(newEvent(FMSConnection.SUSSESS));

break;

case"NetConnection.Connect.Failed":

Logger.debug("FMSConnection:netStatusHandler:Failed:connected:"+this.connected+"-"+event.info.code);

dispatchEvent(newEvent(FMSConnection.FAILURE));

break;

default:

Logger.debug("FMSConnection:netStatusHandler:code:"+event.info.code);

break;

}

}

privatefunctionnetSecurityError(event:SecurityErrorEvent):void{

Logger.error("FMSConnection:netSecurityError:"+event);

}

privatefunctionasyncErrorHandler(event:AsyncErrorEvent):void{

Logger.error("FMSConnection:asyncErrorHandler:"+event.type+"-"+event.error);

}

privatefunctionioErrorHandler(event:IOErrorEvent):void{

Logger.error("FMSConnection:asyncErrorHandler:"+event.type+"-"+event.text);

}

}

}

  

爱华网本文地址 » http://www.413yy.cn/a/25101012/114027.html

更多阅读

中小学教师职业道德规范学习笔记

中小学教师职业道德规范学习笔记一、依法执教。学习和宣传马列主义、毛泽东思想和邓--同志建设有中国特色社会主义理论,拥护党的基本路线,全面贯彻国家教育方针,自觉遵守《教师法》等法律法规,在教育教学中同党和国家的方针政策保持一

伤寒学习笔记(下

伤寒学习笔记---14,桂枝用量问题?学习仲景药法,涉及用量问题。深入考证,固然不必,简单了解,实属必要。仅以桂枝为例,整理如下:基本资料:《现代中医药应用与研究大系》1985年版,简称《大系》。药法:凡例里说:“将其折合今之用量---,并结合笔者临床

关于闪光灯TTL的学习笔记

关于闪光灯TTL的学习笔记(转)俺注:一直对加闪光灯的拍摄比较疑惑,要知道并不是加开个闪光就一了百了的。特别是现在的专业闪灯,有好几种模式,都需要配合相机的测光使用。今天无意之间看到一篇解疑的文章,赶紧收集下来仔细学习。想学习下闪

“Doit,掌控每一天”学习笔记和使用感受

使用感受:学习经历:微信课,4节沪江职场讲座,准备报名参加易仁教主的威海线下活动。以上表明:我对Doit软件学习的决心,不仅仅是因为教主的推荐,更多的是对自我的挑战。参加“沪江网:掌控每一天活动:写感受,拿福利”是我做过的最漂亮的项目类事

声明:《RED5学习笔记二 :RED5项目配置》为网友泛舟碧波湖分享!如侵犯到您的合法权益请联系我们删除