PDA

View Full Version : laszlo and red5 remote sharedobjects


ggavio
03-12-2009, 10:13 AM
has anyone worked with red5 remoteshared objects?

i'm trying to develop some examples with laszlo and red5.

I have been able to broadcast live video with laszlo tags in my chat application.
Now i want to develop the text-message part. i have seen red5chat examples that use sharedobjects to send text messages. Can i implement something like this with laszlo ? I dont want to use persistance connections. or this is the best approach ? any ideas?

julien.lzx
03-13-2009, 08:26 AM
Hello Ggavio,

As I've read in this forum the AMF - remoteObject is a long in demand functionnality.
That's a thing I too would like to see happen.

But Openlaszlo also targets the DHTML runtime: as I understand it AMF is too flash oriented to be implemented.

By the way, how would I do it to implement the red5 chat in a LZX?(from what I know...)
It's quick and dirty : embed your chat in a frame.
It's a solution that have been used to make googleMap work with Openlaszlo(cf laszlocode.com) or embed web contents like in g.ho.st.

The idea is:
1 - Edit the red5/swf/samples/simpleChat.fla. Remove all that's unnecessary : logo, background, (input, button).
2 - Compile the .fla to chat.swf for instance. Embed in a HTML page. Let's call it chat.html.
3 - Edit your LZX file : chat.lzx. Add:
3.1 an edittext
3.2 a send button
3.3 a <html> object which src is chat.html.
(3.4 a colorpicker)
4 - Make it so that the edittext string is send from chat.lzx to chat.html and from chat.html to chat.swf.

Note that's it's even simplier to keep the edittext and button in the swf : no #4 step.

---

Other ideas? well errrr, from the things I've seen here and there :
- Using RPC.
- Build a custom red5 service like in the red5phoneSIP.
Check the extending of rtmpconnection in phoneLib.lzx
http://npramesh.wordpress.com/2008/06/05/web-based-sip-phone-with-flex-java-and-red5-server/
- Creating a JAVA chat : cf openmeetings
- As OpenLaslo is opensource, so it's also to us users to implement AMF if we deadly want it :
-- in the lps4.1.1 rtmpconnection.lzx, the netremotecall.onResult comment is interesting.
-- maybe a workaround is now possible with the as3 passthrough tag.
(I must admit I'm yet too cheap at AS3 dev to try, once I got time and skills...lol)

Hope it helped,

Julien

ggavio
03-13-2009, 02:49 PM
Thanks for the replies. I developed something that works. its not very tidy but it does the job... may be i will refactor later...

sorry for the english but im from Argentina!


<canvas debug="true">

<class name="chatSender">
<attribute name="_netConnection" />
<attribute name="_sharedObject" />

<handler name="oninit">
this._netConnection = new NetConnection();
this._netConnection.connect("rtmp://localhost/oflaDemo/room1");

this._sharedObject = SharedObject.getRemote("chat", this._netConnection.uri, true);
this._sharedObject.connect(this._netConnection);
Debug.write("ChatSender iniciado");
</handler>

<method name="sendMessage" args="mensaje">
Debug.write("SendMessage: " + mensaje )
this._sharedObject.send("messageHandler",mensaje);
</method>
</class>

<class name="chatReceiver">
<attribute name="_netConnection" />
<attribute name="_sharedObject" />

<handler name="oninit"><![CDATA[

this._netConnection = new NetConnection();
this._netConnection.connect("rtmp://localhost/oflaDemo/room1");
Debug.write ("netConnection:" + this._netConnection);

this._sharedObject = SharedObject.getRemote("chat", this._netConnection.uri, true);
this._sharedObject.connect(this._netConnection);
Debug.write ("sharedObject:" + this._sharedObject);

this._sharedObject.messageHandler = function(str) {

var textoAnterior = texto.text;
Debug.write( textoAnterior + "<br/>" + str);
texto.setAttribute("text", textoAnterior + "<br/>" + str);
};
Debug.write ("chatReceiver iniciado");
]]>
</handler>
</class>

<chatReceiver name="chatRec"/>
<chatSender name="chatSen"/>

<simplelayout/>
<view width="400" height="600" bgcolor="red">
<text id="texto" width="400" height="600" multiline="true"/>
</view>
<view bgcolor="red">
<simplelayout axis="x"/>
<inputtext bgcolor="white" width="350" id="mensajeAEnviar"/>
<button width="50" onclick="canvas.chatRec._cajaChat=texto; canvas.enviarTexto(mensajeAEnviar.text);">Enviar</button>
</view>

<method name="enviarTexto" args="texto">
Debug.write("enviarTexto:" + mensajeAEnviar.text);
canvas.chatSen.sendMessage(mensajeAEnviar.text);
mensajeAEnviar.setAttribute("text","");
</method>


</canvas>