cannot set room variables with Java API

Post here all your questions related with SmartFoxServer Java API

Moderators: Bax, Lapo, rjgtav

cannot set room variables with Java API

Postby olafmol » 13 Jan 2009, 18:48

Hello,

we use the code from the documentation to set Room Variables:

Code: Select all
Map<String, RoomVariableRequest> rVars = new HashMap<String, RoomVariableRequest>();
RoomVariableRequest variable = new RoomVariableRequest("2500", SFSVariable.TYPE_NUMBER);
rVars.put("score", variable);
sfs.setRoomVariables(rVars, 4, true);


but when looking in the Administrator tool we cannot see any room variables added, and also the onUpdateRoomVariables event is never triggered.

In the debug info it seems the send variables is empty too? We see <vars></vars> strings, with nothing in them

Olaf
olafmol
 
Posts: 3
Joined: 07 Jan 2009, 21:32
Location: Netherlands

Postby shinsa » 17 Jan 2009, 16:38

Same situation as I experienced.

I think it's bug at getXmlRoomVariable() in SmartFoxClient.java.
In this function, "boolean" should be SFSVariable.TYPE_BOOLEAN, etc.

I fixed them and tried, then socket connection is disconnected just after room variables changing request is sent. Currently I don't know why it occurs...
shinsa
 
Posts: 5
Joined: 24 Dec 2008, 15:53

Postby shinsa » 17 Jan 2009, 16:55

Workaround is found.
Set the room variable when creating a room.
(I experimented room creation in AS3, room variable retrieve in Java)
shinsa
 
Posts: 5
Joined: 24 Dec 2008, 15:53

Postby Lapo » 19 Jan 2009, 06:40

Thanks for reporting. We're taking a look asap
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby franto » 28 Jan 2009, 14:59

Lapo wrote:Thanks for reporting. We're taking a look asap


Hey, is something new with this issue? I have same problem
franto
 
Posts: 3
Joined: 28 Jan 2009, 14:57

Postby Lapo » 28 Jan 2009, 16:15

Hi,
the bug has been fixed. Expect a release in the next days.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Jan 2009, 16:33

Hi there,
we have a pre-release available here:
http://www.smartfoxserver.com/download/ ... I_beta.zip

Please let me know if it fixes the problem
Thank you
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy

Thank you

Postby franto » 31 Jan 2009, 20:41

Lapo wrote:Hi there,
we have a pre-release available here:
http://www.smartfoxserver.com/download/ ... I_beta.zip

Please let me know if it fixes the problem
Thank you


Thank you Lapo, I will test it on Monday and will let you know...

Franto
franto
 
Posts: 3
Joined: 28 Jan 2009, 14:57

Postby Lapo » 04 Feb 2009, 15:21

how did it go?
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy

Basic or Pro?

Postby franto » 04 Feb 2009, 17:20

Lapo wrote:how did it go?


1 question Lapo, does it matter if this is for Lite, Basic or Pro version?
or is it for all versions?
franto
 
Posts: 3
Joined: 28 Jan 2009, 14:57

Postby Lapo » 04 Feb 2009, 18:01

We tested using the PRO, should work well with the Basic and it won't work with the Lite version.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy

Trouble setting variable

Postby alexgenaud » 22 Oct 2009, 13:55

Hi, is it possible this has not been fixed or has regressed in 1.6.6.

I create two rooms, one in the config.xml named "y" with a variable "type=y", then other room I create in a java Task which I expect to be named "c2" with a variable "type=c".

While the "type=y" of the initially created room is seen by both the client and the server, the "type=c2" of the extension created room "c2" is seen by the server but not the client.

Perhaps I've misunderstood private, owner, etc?:


In the config/xml:

Code: Select all
<Room name="y" maxUsers="100"
isPrivate="false" isTemp="false"
uCountUpdate="true" autoJoin="true" limbo="true">
   <Vars>
      <Var name="type" type="s" private="true">y</Var>
   </Vars>
</Room>



In Java Extension:

Code: Select all
Room nwRoom = new Room("c", 10, false, "z");
int id = nwRoom.getId();
nwRoom.setName("c" + id);
nwRoom.setVariable("type", RoomVariable.TYPE_STRING,
"c", true, true, null, true); // and other boolean variations



In client AS:

Code: Select all
logMessage("type/id/name: " +
r.getVariable("type") + "/" +
r.getId() + "/" +
r.getName());



Server side logs:

Code: Select all
y/1/y
c/2/c2



Client side logs:

Code: Select all
y/1/y
undefined/2/c2



Any thoughts?
User avatar
alexgenaud
 
Posts: 13
Joined: 05 Oct 2009, 12:57
Location: Copenhagen, DK

Postby Lapo » 26 Oct 2009, 08:50

Rooms on the server set cannot be created like that.
You need to use the server side API, via the ExtensionHelper class.
From there you find a method call createRoom()

Make sure to take a look at the documentation:
http://www.smartfoxserver.com/docs/docP ... ons.htm#10

And javadoc:
http://www.smartfoxserver.com/docs/docP ... elper.html
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
 
Posts: 16219
Joined: 21 Mar 2005, 09:50
Location: Italy


Return to Java2SE / Android Client API

Who is online

Users browsing this forum: No registered users and 1 guest