[Red5] Does sendMessage send ArrayList to the client correctly?
Walter Tak
walter at waltertak.com
Sat Aug 8 06:02:58 PDT 2009
Well it's officially a List:
protected void sendMessage(String handler, List<?> arguments)
Broadcast event to event handler
See:
http://api.red5.nl/org/red5/server/so/SharedObject.html#sendMessage(java.lang.String,%20java.util.List)
But you get the idea of using just one handler-function on your Flash client and putting data in one object when sending it to Flash.
There are probably fancier ways to do that, maybe someone can step in. Or look in the archives and search for messages with the subject "serialization".
You could send complete objects over to Flash and have Flash unserialize them on the fly.
For simple implementations that might be a bit too complex (e.g. if you only need to send a simple array from Red5 to Flash).
----- Original Message -----
From: David Kim
To: red5 at osflash.org
Sent: Saturday, 08 August 2009 05:31
Subject: Re: [Red5] Does sendMessage send ArrayList to the client correctly?
Thank you for your message.
BTW, can sendMessage have the Object as its second argument?
Anyway, my solution on that issue at that moment was, let the method just return the ArrayList (instead of 'void') after
adding the new item there, and then, on the client side, let the client method get the ArrayList
and, with connection.call and so.send, let the client notify the updates to all other clients, so
that they also can get the updated ArrayList with connection.call and
update their own ArrayList real-time. A very simple trick, and it works well.
David
On Fri, Aug 7, 2009 at 6:01 PM, Walter Tak <walter at waltertak.com> wrote:
Just put the Arraylist in an Object so [sendMessage] won't complain.
If you'd use that for every call to a clientside function then it will be second nature in seconds and on the client you'd only have to look inside the object to see what nice data is inside.
Tbh you could only expose one function in AS with the generic name like "incomingMessage" and have a [switch] based upon the contents of the object.
For example:
so.sendMessage("myFunctionOnTheFlashClient", new Object[] {"msg_id_1", ArrayList} )
On the client you could do a [switch] on the incoming first item inside the object "msg_id_1" and the call the local function with the payload (the ArrayList).
W.
----- Original Message -----
From: David Kim
To: red5 at osflash.org
Sent: Friday, 07 August 2009 23:07
Subject: Re: [Red5] Does sendMessage send ArrayList to the client correctly?
I think I found a trick to handle this, but, still am wondering if Array or ArrayList can be passed
with sendMessage?
Thanks,
David
On Fri, Aug 7, 2009 at 2:53 PM, David Kim <david.qwk at gmail.com> wrote:
Hi,
I'm on Red5 7.0, and wondering if so.sendMessage("ClientMethod", ArrayList) works?
It always gives me the wrong arguments error, like expected 1 argument, but 5 (the number of items of the ArrayList) arguments.....
David
--------------------------------------------------------------------------
_______________________________________________
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/red5_osflash.org/attachments/20090808/5259426c/attachment.html>
More information about the Red5
mailing list