I read about the event USER_ENTER_ROOM at http://docs2x.smartfoxserver.com/api-docs/jsdoc/symbols/SFS2X.SFSEvent.html#.USER_ENTER_ROOM
I want to that when an user enter room, I can get more information such as level, money...from the user. I think so we can use method user.setVariable(). But where do we can set the variables? How to implement that?
I try to implementing code in server. But when the event USER_ENTER_ROOM is fired, I cannot get the variables.
Code: Select all
addEventHandler(SFSEventType.USER_JOIN_ROOM, JoinRoomHandler.class);
Code: Select all
public class JoinRoomHandler extends BaseServerEventHandler {
@Override
public void handleServerEvent(ISFSEvent event) throws SFSException {
User sender = (User) event.getParameter(SFSEventParam.USER);
List<UserVariable> userVars = new ArrayList<UserVariable>();
userVars.add(new SFSUserVariable("avatarType", "SwedishCook"));
userVars.add(new SFSUserVariable("country", "Sweden"));
sender.setVariables(userVars);
}
}
Could you please give me some solution?
Cheer,