[Red5devs] Serverside cast problems with remote shared objects
Valentin Manthei
mail at valentin-manthei.de
Tue May 20 09:13:44 PDT 2008
Hi everybody.
I currently have some problems with handling my remote shared objects in
my webapp.
I save the rso attributes as an ArrayList but when I operated with them
sometimes (not frequently) ClassCastExceptions occurred.
-> java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast
to java.util.ArrayList
Some code snippets:
Adding an user:
ArrayList<String> vl = (ArrayList) viewerList.getAttribute("rso_name");
if(vl == null) {
vl = new ArrayList<String>();
}
vl.add("username");
Removing an user:
ArrayList<String> vl = new ArrayList<String>();
vl = (ArrayList) viewerList.getAttribute("rso_name");
if(vl != null) {
int listsize = vl.size();
if(listsize > 0) {
for(int i=0; i<listsize; i++) {
if(vl.get(i).substring(0,
vl.get(i).indexOf("/")).equals(viewer)) {
vl.remove(i);
break;
}
}
}
viewerList.beginUpdate();
viewerList.setAttribute(broadcaster, vl);
viewerList.endUpdate();
}
I also experimented with storing the rso data in a HashMap but in this
case he told me the cast from ArrayList to HashMap cannot be done. What
the hell? ;-)
Im not sure if thats a red5 or a Java problem, but i hope someone can
help me out of it.
Best regards,
Valentin
More information about the Red5devs
mailing list