red5 v0.9: convert from org.red5.io.utils.ObjectMap to a class
I'm using red5 v0.9 latest svn version.
the function appConnect(Iconnection conn,Object[] params)
provides an array of type ObjectMap.
i would like to convert params[0] to the ConnectParams class that i created:
public class ConnectParams extends Object {
public Double toolkitVersion;
public String gameName;
public Integer userId;
public Integer challengeId;
}
When i try to convert using the following command: ConnectParams param = (ConnectParams)params[0];
i get the following error:
java.lang.ClassCastEx开发者_开发问答ception: org.red5.io.utils.ObjectMap cannot be cast to com.xpogames.ConnectParams
on the Flash side i have the same definition of that same class and i'm sending it as a parameter.
on the red5 java side, if i print params[0].toString() i do see all the keys and values from the ConnectParams class that i sent, which means that the only thing i'm missing is how to convert this ObjectMap to the appropriate class type.
I resolved the issue by casting params[0] to a hashmap and passing it to my class's constructor, in that class i use .get() and .containsKey() in order to populate my class:
ConnectParams param = new ConnectParams((HashMap<String,Object>)params[0]);
精彩评论