Scenerio - (_activeRoom is my private member used to keep track)
Client1:
- logs in to zone
- joins Lobby Room
- joins Game Room 1 - is set to Player1
- sets room vars: ("player1_Name", "name") & ("player1_Char", n)
- 1 at a time
// code snippet from my connection class
public function setRoomVariable(varName:String, varValue:*):void
{
var roomId = getRoomID(_activeRoom);
var vObj = new Array();
vObj.push({name:varName, val:varValue});
sfs.setRoomVariables(vObj, roomId);
}
//
- onRoomVariablesUpdate(evt:SFSEvent) works correctly
- Client1 can call sfs.getRoomVariable("player1_Char") and get the value
- waits here for player 2...
// code snippet
// the updated vars are passed to my game data class and
// parsed into a local dictionary
public function parseGameVars(changedVars:Array, room:Room):void {
for (var i=0; i<changedVars.length; i++){
var varName = changedVars;
var varVal = room.getVariable(varName);
_mpGameVars[varName] = varVal;
}
}
// works perfectly
--- Now ---
Client2:
- logs in to zone (from the IDE)
- joins Lobby Room
- joins Game Room as Player2
- sets room vars ("player2_Name", _activeRoomId)
- onRoomVariablesUpdate(evt:SFSEvent) works correctly
- Client2 can call sfs.getRoomVariable("player2_Name") and get the value
--- However ----
- Client2 calls
_activeRoom.getRoomVariable("player1_Char") to get player 1 info
- returns null
--- Also ---
- using room.getRoomvariables()
- when Client2 gets into Game Room 1 to try and synch up
- with all the variables set already - doesnt' seem to work either.
// code snippet
var rVars = room.getVariables();
for (var i in rVars) {
trace( "var " + i + " = " + rVars );
}
Is this a bug in the AS3 builds? Or am I doing something wrong?
Server Version: 1.4.5 beta
Class Files: sfs_as3_beta2.zip
AS3 - having getVariable problem
I've done a few tests locally with the current build but I wasn't able to reproduce the problem.
Why don't you just use the getActiveRoom() method to retrieve the room you're currently in?
Are you sure _activeRoom is pointing to the recently joined room object?--- However ----
- Client2 calls
_activeRoom.getRoomVariable("player1_Char") to get player 1 info
- returns null
Why don't you just use the getActiveRoom() method to retrieve the room you're currently in?
I'm sure that the room variable points to the correct room - I actually include the roomId when setting the room variable.
smartFox.setRoomVariables(rVars, _roomId)
the reason I'm not using getActiveRoom() is because I don't leave the lobby when I join the game room.
// Docs snippet //
NOTE: SmartFoxServer allows users to be logged in two or more rooms at the same time. If your multiuser application makes use of this feature this API method becomes useless and you should track the room ID(s) of your clients manually, for example by keeping them in an array.
smartFox.setRoomVariables(rVars, _roomId)
the reason I'm not using getActiveRoom() is because I don't leave the lobby when I join the game room.
// Docs snippet //
NOTE: SmartFoxServer allows users to be logged in two or more rooms at the same time. If your multiuser application makes use of this feature this API method becomes useless and you should track the room ID(s) of your clients manually, for example by keeping them in an array.
That's correctthe reason I'm not using getActiveRoom() is because I don't leave the lobby when I join the game room.
We've run more a few more tests, recreated the scenario and found the problem, which is now fixed.
We've updated the online package, but you can also use this link to just download the updated files -> http://www.smartfoxserver.com/temp/AS3_API_b3.zip
Hope it helps