9/9/2010 7:32:26 AM
Title:
sending parameters to red5 and retrieve them back in flex3
Through nc.call("sendMessage",null,str,boo); i would like to pass both str is a string variable and boo is a boolean variable parameters to red5 and from there i would llike to get both the values in flex application. i can send one parameter and can retrieve it, but 2nd parameter if i m passing wat will be the server side code and how to retrieve back.
Server code:
public void sendMessage(List<String> params) {
msgs_so = getSharedObject(roomScope, "message");
msgs_so.setAttribute("receiveMessage", params);
msgs_so.sendMessage("receiveMessage",params);
}
with this i can receive one message and can broadcast to all clients who share the same msgs_so(sharedObject). if i m passing 2 params and my server code is,
public void updates(Object[] params) { String update_msg = (String)params[0]; boolean update_var = (Boolean) params[1]; ..............? }
something like above but how to read them at client side and server side using red5 and flex3. thanks in advance.
9/9/2010 8:37:52 PM
In actionscript 3 you need to setProperty for each new parameter in sharedObject like this
msgs_so.setProperty("mess1", param1);
msgs_so.setProperty("mess2", param2);
msgs_so.setProperty("mess3", param3);
now you will receive these three parameters in the same sharedObject listener declared on the other clients and server.
Listener function is declared like this
//attach sync listener which will be triggered whenever a property is changed
msgs_so.addEventListener(SyncEvent.SYNC, syncHandler);
private function syncHandler(event:SyncEvent):void {
//here you will receive your messages on all the clients
var mes1 = so.data.mess1;
var mes2 = so.data.mess2;
var mes3 = so.data.mess1;
}
9/10/2010 1:02:19 AM
hi,
thanks for ur reply. i dont have to show the params on client side. on receiving each param different functions has to be called. so wat will be the code on server side in (Application.java).