setUserVariables messes up ?
Posted: 08 Nov 2007, 16:35
This java-code in a room extension:
Results in this xml-code sended to the client:
As you can see, the second userVarsUpdate has a double user-tag in it.
How can I change the serverside extension so that this error won't occur anymore ?
Code: Select all
// Set userVariable 'readyForNewRound' on all players
User[] players = currRoom.getAllPlayers();
int numPlayers = players.length;
HashMap<String,UserVariable> userVars = new HashMap<String,UserVariable>();
userVars.put("readyForNewRound", new UserVariable("1",UserVariable.TYPE_BOOLEAN));
this.numPlayersReady = 0;
for(int i =0;i < numPlayers; i++){
helper.setUserVariables(players[i], userVars, true);
this.numPlayersReady++;
}
Code: Select all
[ RECEIVED ]: <msg t='sys'><body action='uVarsUpdate' r='24'><vars><var n='readyForNewRound' t='b'><![CDATA[1]]></var></vars><user id='35' /></body></msg>, (len: 140)
userVarsUpdate
false
[ RECEIVED ]: <msg t='sys'><body action='uVarsUpdate' r='24'><vars><var n='readyForNewRound' t='b'><![CDATA[1]]></var></vars><user id='34' /><user id='34' /></body></msg>, (len: 156)
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleUserVarsUpdate()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::xmlReceived()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleSocketData()
How can I change the serverside extension so that this error won't occur anymore ?