[Red5] Creating chatromm. How to send to any clients ?

Patrice FERLET metal3d at gmail.com
Fri Feb 15 12:27:49 PST 2008


allright, this is how i did for my test. It's very simple, quickly coded and
it works. I did it on openLaszlo, but you can easilly convert it for you
Flash generators:

<canvas debug="true">
<script>
//create my NetConntection
mync = new NetConnection();
mync.connect("rtmp://localhost/MyApp");

mync.onStatus = function (state){
    if(state.code == "NetConnection.Connect.Success"){
        createSharedObject();
    }
}


function createSharedObject(){

   so = SharedObject.getRemote("test", mync.uri, false); // fals = if every
clients are disconnected, the shared object is deleted on server

   // I declare the "testMsg" handler
    so.testMsg = function (msg){
        Debug.write('Get Message');
        Debug.write(msg) // write "Hello" on my debug trace
    }
    so.connect(mync);

}
</script>

<button text="Test send Hello">
    <handler name="onclick">
        //I send "Hello" to testMsg handlers on every clients
        so.send("testMsg","Hello");
    </handler>
</button>
</canvas>


Open 2 players, and press the button... both clients get "Hello".
MyApp is an empty application for now. It's works !

Very very nice ! I love !

2008/2/15, Patrice FERLET <metal3d at gmail.com>:
>
> I just looked how it works. Shared Objects are really nices.
> In fact, there is 2 shared objects you can use:
>   - local -> works like a cookie
>   - remote -> works like a pipe
>
> If you get a SharedObject from Red5, you could get informations by
> listening events:
>   - onSync
>   - onRelease
>
> I am working with it and i will purpose tutorials this week end. Not too
> bad for a novice, isn't it ? :)
>
> PS: excuse my french english :)
>
>
> 2008/2/15, Ignacio Lopez <ignacio.lopez at gmail.com>:
> >
> > I have implemented a very simple chat system with red5 and openlaszlo
> > using rtmp calls and server side state, and it's working fine so far.
> > However, i'am not so familiar with the sharedobject approach. What would be
> > the differences / benefits of using the shared object approach instead of
> > the traditional calls between clients and server?
> >
> > On Fri, Feb 15, 2008 at 7:52 AM, Joao Henrique Silva Santos <
> > joao.s.santos at gmail.com> wrote:
> >
> > > It is a shame to say it, but I still have not played with shared
> > > objects and don't know the syntax, so I cannot help you. For the
> > > moment I am using the "invoke" approach.
> > > I would like to see other people responses, though.
> > >
> > > joao
> > >
> > > On 15/02/2008, Patrice FERLET <metal3d at gmail.com> wrote:
> > > > In my last message, replace "oflaDemo" by "SOSample". I'm looking on
> > > API
> > > > documentation to find the way. I learn lot of good knowlegdes by
> > > reading
> > > > API.
> > > >
> > > > 2008/2/15, Patrice FERLET <metal3d at gmail.com>:
> > > > > While you answered me, I was seeking again on red5 examples. I
> > > founded the
> > > > SimpleChat example working very well.
> > > > > It seems to use oflaDemo application to connect and send
> > > messages... but
> > > > java sources are empties. I looked into directories and i found the
> > > > simpleChat.fla sources...
> > > > >
> > > > > But on Linux, i can't decompile fla files to see how it works. I
> > > didn't
> > > > tried your code yet, but it seems that we can do it simply with
> > > > SharedObject, right ?
> > > > >
> > > > > I'm not using flex but openlaszlo, working fine with red5.
> > > > >
> > > > > Thanks for your help.
> > > > >
> > > > >
> > > > >
> > > > > 2008/2/14, Joao Henrique Silva Santos <joao.s.santos at gmail.com>:
> > > > >
> > > > > > also, you may need to define a function on your client side:
> > > > > >
> > > > > > public function onBWDone()
> > > > > >
> > > > > > {
> > > > > > }
> > > > > >
> > > > > > On 14/02/2008, Patrice FERLET <metal3d at gmail.com> wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > > Well, now I have created a first application wich can get
> > > messages
> > > > from my
> > > > > > > client.
> > > > > > > Remember that i begin on Red5 developpement :)
> > > > > > >
> > > > > > > What i did is a simple callable method: public String
> > > > sendMessage(String
> > > > > > > clientname, String msg)...
> > > > > > >  My client send a message via NetConnection and i log my
> > > message.
> > > > Everything
> > > > > > > is allright :) But how can I send this message on clients
> > > connected to
> > > > my
> > > > > > > app ?
> > > > > > >
> > > > > > > Client have a "onResult" connection handler wich can get
> > > returned
> > > > values...
> > > > > > > but only for my client calls...
> > > > > > >
> > > > > > > my Application run in Singleton. Have clients to "check"
> > > messages
> > > > every 500
> > > > > > > ms? or is there another way to have my messages as stream ?
> > > > > > >
> > > > > > > I dont find any example on internet, if you can help me to
> > > find my way
> > > > :)
> > > > > > >
> > > > > > > PS: In fact, Red5 isn't complicated... I just miss some
> > > advanced
> > > > tutorials.
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Blog: http://www.metal3d.org
> > > > > > > Copix: http://www.copix.org
> > > > > >
> > > > > > > _______________________________________________
> > > > > > >  Red5 mailing list
> > > > > > >  Red5 at osflash.org
> > > > > > >  http://osflash.org/mailman/listinfo/red5_osflash.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > Red5 mailing list
> > > > > > Red5 at osflash.org
> > > > > > http://osflash.org/mailman/listinfo/red5_osflash.org
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > > Blog: http://www.metal3d.org
> > > > > Copix: http://www.copix.org
> > > >
> > > >
> > > >
> > > > --
> > > > Blog: http://www.metal3d.org
> > > > Copix: http://www.copix.org
> > > > _______________________________________________
> > > >  Red5 mailing list
> > > >  Red5 at osflash.org
> > > >  http://osflash.org/mailman/listinfo/red5_osflash.org
> > > >
> > > >
> > >
> > > _______________________________________________
> > > Red5 mailing list
> > > Red5 at osflash.org
> > > http://osflash.org/mailman/listinfo/red5_osflash.org
> > >
> >
> >
> > _______________________________________________
> > Red5 mailing list
> > Red5 at osflash.org
> > http://osflash.org/mailman/listinfo/red5_osflash.org
> >
> >
>
>
> --
> Blog: http://www.metal3d.org
> Copix: http://www.copix.org
>



-- 
Blog: http://www.metal3d.org
Copix: http://www.copix.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5_osflash.org/attachments/20080215/6fd03a7d/attachment.html 


More information about the Red5 mailing list