[Red5] Accessing SharedObject to get last message
Cristian Rusu
crirus at gmail.com
Thu Oct 1 22:43:05 PDT 2009
Hello Mario,
I use to do that to let users edit their last messages Skype fashion.
It's a matter of how you store a message in the SO. See below for an idea
//id is the message I want to edit, bottom up.
ObjectMap<String, Object> msg = new ObjectMap<String, Object>();
int id;
Calendar cal = Calendar.getInstance();
cal.add(
Calendar.MILLISECOND,
-cal.get(Calendar.DST_OFFSET) -
cal.get(Calendar.ZONE_OFFSET)
);
if(historyIndex==0){
id = text_chat_id++;
if(text_chat_id>300) text_chat_id = 1;
msg.put("id", id);
msg.put("b", client.isBroadcaster);
msg.put("time", cal.getTime().getTime());//we save GMT of the
message
msg.put("date",
cal.get(Calendar.YEAR)+"/"+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.DAY_OF_MONTH));//we
save GMT of the message
msg.put("user", client.name);
msg.put("user_id", client.uid);
msg.put("user_icon", client.icon);
msg.put("user_gender", client.gender);
}else{
id = text_chat_id-historyIndex;
try{
Object o = text_chat_so.getAttribute(Integer.toString(id));
msg = (ObjectMap<String, Object>) o;
msg.put("edit_time", cal.getTime().getTime());//we save GMT
of the message
msg.put("edit_date",
cal.get(Calendar.YEAR)+"/"+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.DAY_OF_MONTH));//we
save GMT of the message
}catch(Exception e){}
text_chat_so.removeAttribute(Integer.toString(id));
}
msg.put("txt", message);
_______________
Sincerely
Cristian Rusu
==============
2009/10/1 Mário Júnior <juninhog12 at gmail.com>
> Hello all! How are you?
>
> So, how do I get a SharedObject to get the last message from Server?
> (accessing from Java, not AS3 SYNC event).
> I need to store all conversations as history in the stream, but I want not
> get them from AS3... I believe that is more easy way to do this task from
> server.
>
> Any suggestion?
>
> Thanks and best regards from Brazil.
>
>
>
> --
> Mario Junior
> Enterprise Java / Flex Architectures
> Adobe Certified Expert Flex 3 with AIR
>
> Sofshore Informática
> http://www.sofshore.com.br
> +55 (48) 3337 2003
> Rua Pastor Willian Richard Schisler Filho 452 sl 102, 88034-100 Itacorubi
> Florianopolis SC Brasil
>
> _______________________________________________
> 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/20091002/80ab0547/attachment.html>
More information about the Red5
mailing list