[Red5commits] [1643] added echo sample application + flex2 program

jbauch luke at codegent.com
Wed Jan 24 11:13:34 EST 2007


added echo sample application + flex2 program


Timestamp: 01/21/07 17:54:02 EST (3 days ago) 
Change: 1643 
Author: jbauch

Files (see diff or trac for details): 
java/server/branches/joachim_amf3_integration/.classpath
java/server/branches/joachim_amf3_integration/build.xml
java/server/branches/joachim_amf3_integration/swf/DEV_Source/classes/org/red5/samples/echo
java/server/branches/joachim_amf3_integration/swf/DEV_Source/classes/org/red5/samples/echo/EchoClass.as
java/server/branches/joachim_amf3_integration/swf/DEV_Source/echotest.mxml
java/server/branches/joachim_amf3_integration/webapps/echo
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/log4j.properties
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.properties
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.xml
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp/echo
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp/echo/Application.java
java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/web.xml


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1643

Index: /java/server/branches/joachim_amf3_integration/build.xml
===================================================================
--- /java/server/branches/joachim_amf3_integration/build.xml (revision 1447)
+++ /java/server/branches/joachim_amf3_integration/build.xml (revision 1643)
@@ -64,4 +64,6 @@
 		<mkdir dir="${testclass.dir}"/>
 		<mkdir dir="${testreports.dir}"/>
+		<mkdir dir="${src.dir}/../webapps/echo/WEB-INF/classes"/>
+		<mkdir dir="${src.dir}/../webapps/echo/WEB-INF/lib"/>
 		<mkdir dir="${src.dir}/../webapps/fitcDemo/WEB-INF/classes"/>
 		<mkdir dir="${src.dir}/../webapps/fitcDemo/WEB-INF/lib"/>
@@ -84,4 +86,6 @@
 		<delete dir="${javadoc.dir}"/>
 		<delete dir="${testdoc.dir}"/>
+		<delete dir="${src.dir}/../webapps/echo/WEB-INF/classes"/>
+		<delete dir="${src.dir}/../webapps/echo/WEB-INF/lib"/>
 		<delete dir="${src.dir}/../webapps/fitcDemo/WEB-INF/classes"/>
 		<delete dir="${src.dir}/../webapps/fitcDemo/WEB-INF/lib"/>
@@ -130,4 +134,20 @@
             listfiles="false"      
             />
+
+		<javac
+			sourcepath=""
+			srcdir="${src.dir}/../webapps/echo/WEB-INF/src"
+			destdir="${src.dir}/../webapps/echo/WEB-INF/classes"
+			classpathref="webapps.classpath"
+            optimize="${build.optimize}" 
+            verbose="${build.verbose}" 
+            fork="${build.fork}" 
+            nowarn="${build.nowarn}"
+            deprecation="${build.deprecation}"
+            debug="${debug.state}"
+            compiler="${compiler}"
+            source="${java.target_version}"
+            target="${java.target_version}" 
+		/>
 
 		<javac
@@ -396,4 +416,10 @@
 		</jar>
 		
+		<jar destfile="${src.dir}/../webapps/echo/WEB-INF/lib/echo.jar">
+			<fileset dir="${src.dir}/../webapps/echo/WEB-INF/classes">
+				<include name="**"/>
+			</fileset>
+		</jar>
+		
 		<jar destfile="${src.dir}/../webapps/fitcDemo/WEB-INF/lib/fitcDemo.jar">
 			<fileset dir="${src.dir}/../webapps/fitcDemo/WEB-INF/classes">
Index: /java/server/branches/joachim_amf3_integration/swf/DEV_Source/echotest.mxml
===================================================================
--- /java/server/branches/joachim_amf3_integration/swf/DEV_Source/echotest.mxml (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/swf/DEV_Source/echotest.mxml (revision 1643)
@@ -0,0 +1,182 @@
+<?xml version="1.0"?>
+<!-- @mxmlc -library-path+=./classes -source-path+=./classes -->
+<mx:Application
+	pageTitle="AMF3 Echo Client"
+	xmlns:mx="http://www.adobe.com/2006/mxml"
+	xmlns:fx="com.fusiox.ui.*"
+	initialize="initApp()"
+	backgroundColor="#F4F4F4" themeColor="haloBlue" layout="vertical">
+
+    <mx:Script>
+    <![CDATA[
+		import mx.controls.Alert;
+		import org.red5.samples.echo.EchoClass;
+		
+		[Bindable]
+		private var nc: NetConnection;
+		
+		[Bindable]
+		private var testParams: Array;
+		
+		[Bindable]
+		private var testIndex: Number;
+		
+		[Bindable]
+		private var testsFailed: Number;
+		
+        private function initApp(): void
+        {
+			// Prepare test values
+			testParams = new Array();
+			testParams.push(null);
+			testParams.push(true);
+			testParams.push(false);
+			testParams.push("");
+			testParams.push("Hello world!");
+			testParams.push(0);
+			testParams.push(1);
+			testParams.push(-1);
+			testParams.push(256);
+			testParams.push(-256);
+			testParams.push(65536);
+			testParams.push(-65536);
+			testParams.push(0.0);
+			testParams.push(1.5);
+			testParams.push(-1.5);
+			testParams.push(new Array());
+			var tmp1: Array = new Array();
+			tmp1.push(1);
+			testParams.push(tmp1);
+			testParams.push(new Array(1, 2));
+			testParams.push(new Array(1, 2, 3));
+			var tmp2: Array = new Array();
+			tmp2.push(1);
+			tmp2[100] = 100;
+			testParams.push(tmp2);
+			var tmp3: Array = new Array();
+			tmp3.push(1);
+			tmp3["one"] = 1;
+			testParams.push(tmp3);
+			var tmp4: Object = {a: "foo", b: "bar"};
+			testParams.push(tmp4);
+			var tmp5: Array = new Array();
+			tmp5.push(tmp4);
+			tmp5.push(tmp4);
+			testParams.push(tmp5);
+			var now: Date = new Date();
+			testParams.push(now);
+			var tmp6: Array = new Array();
+			tmp6.push(now);
+			tmp6.push(now);
+			testParams.push(tmp6);
+			var tmp7: EchoClass = new EchoClass();
+			tmp7.attr1 = "one";
+			tmp7.attr2 = 1;
+			testParams.push(tmp7);
+			nc = new NetConnection();
+			nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
+			onConnect(ObjectEncoding.AMF3);
+        }
+		
+		private function onConnect(proto: uint): void {
+			if (nc.connected) {
+				nc.close();
+			}
+			nc.objectEncoding = proto;
+			nc.connect("rtmp://localhost/echo");
+			textArea.text = "Connecting using " + proto + "...\n";
+		}
+		
+		private function netStatusHandler(event: NetStatusEvent): void {
+			textArea.text += event.info.code + ": " + event.info.description + "\n";
+			switch(event.info.code) {
+				case "NetConnection.Connect.Success":
+					btnTest.enabled = true;
+					onTest();
+				break;
+				case "NetConnection.Connect.Failed":
+					btnTest.enabled = false;
+				break;
+			}
+		}
+		
+		private function doTest(): void {
+			textArea.text += "Testing " + testParams[testIndex] + ": ";
+			nc.call("echo", new Responder(this.onResult), testParams[testIndex]);
+		}
+		
+		private function onTest(): void {
+			testIndex = 0;
+			testsFailed = 0;
+			doTest();
+		}
+		
+		private function extendedEqual(a: Object, b: Object): Boolean {
+			var key: String;
+			if (a == null && b != null) {
+				return false;
+			} else if (a != null && b == null) {
+				return false;
+			} else if (a is Array && b is Array) {
+				if (a.length != (b as Array).length) {
+					return false;
+				}
+				var i: Number;
+				for (i=0; i<(a as Array).length; i++) {
+					if (!extendedEqual((a as Array)[i], (b as Array)[i])) {
+						return false;
+					}
+				}
+				return true;
+			} else if (a is Object && !(b is Object)) {
+				for (key in a) {
+					if (!extendedEqual(a[key], (b as Array)[key])) {
+						return false;
+					}
+				}
+				return true;
+			} else if (!(a is Object) && b is Object) {
+				for (key in b) {
+					if (!extendedEqual((a as Array)[key], b[key])) {
+						return false;
+					}
+				}
+				return true;
+			} else if (a is Object && b is Object) {
+				for (key in a) {
+					if (!extendedEqual(a[key], b[key])) {
+						return false;
+					}
+				}
+				return true;
+			} else {
+				return (a == b);
+			}
+		}
+		
+		private function onResult(result: Object): void {
+		    if (extendedEqual(testParams[testIndex], result)) {
+				textArea.text += "OK\n";
+			} else {
+				textArea.text += "FAILED (" + result.toString() + ")\n";
+				testsFailed++;
+			}
+			testIndex += 1;
+			if (testIndex < testParams.length) {
+				doTest();
+			} else if (testsFailed == 0) {
+				textArea.text += "Successfully ran " + testParams.length + " tests\n";
+			} else {
+				textArea.text += "Ran " + testParams.length + " tests, " + testsFailed + " failed\n";
+			}
+		}
+
+    ]]>
+    </mx:Script>
+	
+	<mx:Button id="btnConnect0" label="Connect AMF0" labelPlacement="left" click="onConnect(ObjectEncoding.AMF0)" />
+	<mx:Button id="btnConnect3" label="Connect AMF3" labelPlacement="left" click="onConnect(ObjectEncoding.AMF3)" />
+	<mx:Button id="btnTest" label="Test" labelPlacement="left" click="onTest()" enabled="false" />
+	<mx:TextArea id="textArea" width="400" height="100%">
+    </mx:TextArea>
+</mx:Application>
Index: /java/server/branches/joachim_amf3_integration/swf/DEV_Source/classes/org/red5/samples/echo/EchoClass.as
===================================================================
--- /java/server/branches/joachim_amf3_integration/swf/DEV_Source/classes/org/red5/samples/echo/EchoClass.as (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/swf/DEV_Source/classes/org/red5/samples/echo/EchoClass.as (revision 1643)
@@ -0,0 +1,8 @@
+package org.red5.samples.echo {
+
+public class EchoClass {
+	public var attr1: String;
+	public var attr2: Number;
+}
+
+}
Index: /java/server/branches/joachim_amf3_integration/.classpath
===================================================================
--- /java/server/branches/joachim_amf3_integration/.classpath (revision 1625)
+++ /java/server/branches/joachim_amf3_integration/.classpath (revision 1643)
@@ -2,4 +2,5 @@
 <classpath>
 	<classpathentry excluding=".svn/*" kind="src" path="src"/>
+	<classpathentry excluding=".svn/*" kind="src" path="webapps/echo/WEB-INF/src"/>
 	<classpathentry excluding=".svn/*" kind="src" path="webapps/tutorial/WEB-INF/src"/>
 	<classpathentry excluding=".svn/*" kind="src" path="webapps/fitcDemo/WEB-INF/src"/>
@@ -17,5 +18,5 @@
 	<classpathentry excluding=".svn/*" kind="src" path="webapps/test/WEB-INF/src"/>
 	<classpathentry kind="lib" path="lib/quartz-1.5.2.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/xmlrpc-2.0.1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
Index: /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.properties
===================================================================
--- /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.properties (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.properties (revision 1643)
@@ -0,0 +1,2 @@
+webapp.contextPath=/echo
+webapp.virtualHosts=*
Index: /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp/echo/Application.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp/echo/Application.java (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/src/org/red5/server/webapp/echo/Application.java (revision 1643)
@@ -0,0 +1,42 @@
+package org.red5.server.webapp.echo;
+
+/*
+ * RED5 Open Source Flash Server - http://www.osflash.org/red5
+ * 
+ * Copyright (c) 2006 by respective authors (see below). All rights reserved.
+ * 
+ * This library is free software; you can redistribute it and/or modify it under the 
+ * terms of the GNU Lesser General Public License as published by the Free Software 
+ * Foundation; either version 2.1 of the License, or (at your option) any later 
+ * version. 
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License along 
+ * with this library; if not, write to the Free Software Foundation, Inc., 
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+ */
+
+import org.red5.server.adapter.ApplicationAdapter;
+
+/**
+ * Echo sample application.
+ * 
+ * @author The Red5 Project (red5 at osflash.org)
+ * @author Joachim Bauch (jojo at struktur.de)
+ */
+public class Application extends ApplicationAdapter {
+
+	/**
+	 * Return passed parameter back to client.
+	 * 
+	 * @param param		Parameter to return.
+	 * @return			Passed parameter.
+	 */
+    public Object echo(Object param) {
+    	return param;
+    }
+
+}
Index: /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.xml
===================================================================
--- /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.xml (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/red5-web.xml (revision 1643)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+	
+	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+	    <property name="location" value="/WEB-INF/red5-web.properties" />
+	</bean>
+	
+	<bean id="web.context" class="org.red5.server.Context" 
+		autowire="byType" />
+	
+	<bean id="web.scope" class="org.red5.server.WebScope"
+		 init-method="register">
+		<property name="server" ref="red5.server" />
+		<property name="parent" ref="global.scope" />
+		<property name="context" ref="web.context" />
+		<property name="handler" ref="web.handler" />
+		<property name="contextPath" value="${webapp.contextPath}" />
+		<property name="virtualHosts" value="${webapp.virtualHosts}" />
+	</bean>
+
+	<bean id="web.handler" 
+	    class="org.red5.server.webapp.echo.Application" 
+		singleton="true" />
+
+</beans>
Index: /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/log4j.properties
===================================================================
--- /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/log4j.properties (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/log4j.properties (revision 1643)
@@ -0,0 +1,1 @@
+# logging config, this should be auto reloaded by spring.
Index: /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/web.xml
===================================================================
--- /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/web.xml (revision 1643)
+++ /java/server/branches/joachim_amf3_integration/webapps/echo/WEB-INF/web.xml (revision 1643)
@@ -0,0 +1,48 @@
+<?xml version="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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
+   version="2.4"> 
+
+	<display-name>Red5 echo application</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>
+	
+	<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>/echo</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>
+
+</web-app>


Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.



More information about the Red5commits mailing list