Browsing articles in "Red5"

Red5 Chat in Flex 4 – Gumbo

Apr 12, 2010   //   by admin   //   ActionScript 3.0, Flash, Flash Develop, Flex, Red5  //  No Comments

Een simple chat aplicatie met red5 en flex4 sdk with flashdevelop.. Het is leuk om hiermee te starten en verder ontwikkellen tot een uitgebeide chat applicatie…

hier is de mxml code:
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
minWidth=”1024″ minHeight=”768″
initialize=”TextSO()”>

<!– Messaging Declarations –>

<!– UI Declarations –>

<s:Panel title=”Simple Flex Chat”>
<mx:TextArea id=”textAreaChat” valueCommit=”textAreaChat.verticalScrollPosition=textAreaChat.maxVerticalScrollPosition”
width=”385″ height=”220″ y=”20″
>
</mx:TextArea>
<s:TextInput id=”textInput” width=”385″  />
<mx:ControlBar horizontalAlign=”center” width=”385″>
<s:Button id=”button” label=”Send” click=”sendMsg(event)” />
</mx:ControlBar>
</s:Panel>

<!– Event-Handling Script –>

<fx:Script>
<![CDATA[
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.SyncEvent;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
import flash.net.SharedObject;
import flash.net.NetConnection;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import mx.events.ChildExistenceChangedEvent;

private var outputText:TextField;
//private var button:Button;
private var text_so:SharedObject;
private var nc:NetConnection;
//private var textArea:TextArea;
//private var textInput:TextInput;
private var rtmpGo:String;
private var good:Boolean;
private var noName:Boolean;
//private var msg:String = "msg";

public function TextSO ():void
{
/* //Set up UIs
textArea=new TextArea();
textArea.setSize (200,300);
textArea.move (20,20);
addChild (textArea);

textInput=new TextInput();
textInput.move (20,330);
addChild (textInput);

button=new Button();
button.width=50;
button.label="Send";
button.move (125,330);*/
//button.addEventListener (MouseEvent.CLICK,sendMsg);
//addChild (button);
/*outputText = new TextField();
outputText.x = 10;
outputText.y = 10;
outputText.background = true;
outputText.autoSize = TextFieldAutoSize.LEFT;
addChild(outputText);*/

textInput.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);

//textInput.setFocus();

rtmpGo = "rtmp://87.211.215.87/test1";
nc = new NetConnection( );
nc.connect (rtmpGo);
nc.addEventListener (NetStatusEvent.NET_STATUS,doSO);
}

private function keyHandler(event:KeyboardEvent):void {

var curKeyCode:int = event.keyCode;
if (curKeyCode == 13) {
sendMsg1();
}

}

private function doSO (e:NetStatusEvent):void
{
good=e.info.code == "NetConnection.Connect.Success";
if (good)
{
trace(e.info.code);
//Set up shared object
text_so=SharedObject.getRemote("test",nc.uri,false);
text_so.connect (nc);
text_so.addEventListener (SyncEvent.SYNC, checkSO);

}
}
private function checkSO (e:SyncEvent):void
{
for (var chng:uint; chng<e.changeList.length; chng++)
{
switch (e.changeList[chng].code)
{
case “clear” :
break;

case “success” :
trace (text_so.data.msg);
break;

case “change” :
textAreaChat.text += text_so.data.msg + “\n”;
//textAreaChat.appendText(text_so.data.msg + “\n”);
break;
}
}
}

private function sendMsg (e:MouseEvent):void
{
noName= (textInput.text==”");
if (noName)
{

}else{
//textAreaChat.htmlText += textInput.text + “\n”;
text_so.setProperty (“msg”, textInput.text);
//textAreaChat.appendText (textInput.text + “\n”);
textAreaChat.text += textInput.text + “\n”;

textInput.text = “”;
}
}

private function sendMsg1 ():void
{
noName= (textInput.text==”");
if (noName)
{

}else{

text_so.setProperty (“msg”,textInput.text);
textAreaChat.text += textInput.text + “\n”;
//outputText.appendText (textInput.text + “\n”);
textInput.text = “”;
}
}
]]>
</fx:Script>

</s:Application>

Red5 installatie op CentOS 5.4

Apr 12, 2010   //   by admin   //   Flash, Red5, linux  //  4 Comments

1) stap:
CentOS komt met java opensdk, dus je kunt het met yum installeren:
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

2)stap:
Download ANT en plaats het in /usr/local
cd /usr/src
wget http://mirrors.kahuki.com/apache/ant/binaries/apache-ant-1.8.0-bin.tar.bz2
tar jxvf apache-ant-1.8.0-bin.tar.bz2
mv apache-ant-1.8.0 /usr/local/ant

3) stap:
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip

4) stap:
Download red5 van met svn van hun red5 site of neem een stabiele versie van hun website. Ik doe het met trunk versie.
cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist

Als je Build Succesfull krijgt dan is installatie gelukt.

Nu is het geinstalleert in folder dist haal het naar de red5 folder en start red5:
cp -r dist/conf .
sh red5.sh

Al het gestart is dan kun je testen op localhost:5080/ als je red5 pagina ziet dan heb je red5 met succes geinstaleert!