Room variables update issue

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Room variables update issue

Postby Madhav » 21 Mar 2013, 05:10

Hi all,
I've been trying to build homes for avatars with different models. The avatar homes are the different openspace maps.
An avatar enters home(opespace map) clicks a button there to upgrade its home, chooses one of the model and returns back to home.
Essentially what i am doing is when user clicks upgrade button showing a panel of different models and unloading the openspace map from back.
When user clicks a model, updating the avatars home's room variables and loading the openspace map again and closing the panel.

The different room variables corresponds to different openspace maps(avatar homes).

The problem i am facing is when i update the room variables and load the map again, the openspace map is not displayed on the stage!!!
The stage is blank and no errors thrown, but traces show me openspace is rendered fine and avatar is created.

Please guide me....
Thanks...
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Room variables update issue

Postby Bax » 21 Mar 2013, 10:46

Home selection apart, this should be just like loading any other map.
Very difficult to understand why the map is not rendering. Are you sure all the assets (skins) to display the new map are loaded by the client?
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 21 Mar 2013, 11:07

Thanks for reply....

Bax wrote: Are you sure all the assets (skins) to display the new map are loaded by the client?

I think it is since traces tel me
"Map loaded, now assets swf files can be loaded
External swf files to be loaded: HomeSkins.swf,HomeBG.swf
External libraries loaded, now the loaded map can be rendered"

Bax wrote:Very difficult to understand why the map is not rendering.

And I even think that map rendering is just fine since traces show
"[INFO] Map generation completed (77 ms)
[INFO] Avatar '321' created in (9,9,0)
[INFO] Avatars creation completed
[INFO] Map rendering completed
OpenSpace.MAP_RENDERED event received"

Also if I don't unload, jst show a panel on stage and update room variables and then close panel and do not load the map, then I see the old map but the changed room variables does not reflect and even my avatar cant walk!!!?

Please help...
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 25 Mar 2013, 05:26

Hey, Please someone do help me....
Till now I was trying to update the room variables from client side.... So now I changed it to server side.....

What I am doing is Home is a room+openspace map whoes variables need to be updated.... I am joining a room called Shop which is simply a sfs room no openspace map attached to it and from there I am trying to update the room variables of Home room(a map).....
Here's my client doing in Shop room,

private function buyNewHome(e:Event):void
{
smartFox.addEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, onRoomVarsUpdate);
var roomVars:Array = [];
var roomName:String = smartFox.mySelf.name+"'s_home";
var room:Room = smartFox.getRoomByName(roomName);
..................................
var mapValue:String = "Home"+inc+"#m0_Map";

var obj:ISFSObject = new SFSObject();
obj.putUtfString("roomName",roomName);
obj.putUtfString("id",mapValue);

smartFox.addEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
var request:ExtensionRequest = new ExtensionRequest("UpdateRoom", obj, room);
smartFox.send(request);
}
}

private function OnExtensionResponse(event:SFSEvent):void
{
var obj:SFSObject = event.params.params as SFSObject;
if(event.params.cmd == "UpdateRoom")
{
trace("output="+obj.getUtfString("output"));
}
}

private function onRoomVarsUpdate(evt:SFSEvent):void
{
trace("ROOM VARIABLES UPDATED");
}

And the serverside code is,

public class UpdateRoomHandler extends BaseClientRequestHandler {

@Override
public void handleClientRequest(User sender, ISFSObject params) {
// TODO Auto-generated method stub
String roomName = params.getUtfString("roomName");
String id = params.getUtfString("id");

List<RoomVariable> roomVars = new ArrayList<RoomVariable>();
roomVars.add(new SFSRoomVariable("_os_mapId", id));
ISFSApi smartfox = SmartFoxServer.getInstance().getAPIManager().getSFSApi();
smartfox.setRoomVariables(sender, getParentExtension().getParentZone().getRoomByName(roomName), roomVars);

Room room = getParentExtension().getParentZone().getRoomByName(roomName);
smartfox.sendExtensionResponse("UpdateRoom", params, getParentExtension().getParentZone().getRoomByName(roomName).getUserList(), room, false);

ISFSObject output = new SFSObject();
output.putUtfString("output", "room variables updated");

WorldManager parentEx = (WorldManager) getParentExtension();
parentEx.send("output", output, sender);
}

}

The extension is attached to the Shop room.... But The room variables are not updated!!!???? Even I didn't get extension response....

What I am doing wrong????
Please reply....
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Room variables update issue

Postby rjgtav » 25 Mar 2013, 12:04

Hi,

You say that the extension is attached to the Shop room, but when you're sending the ExtensionRequest, you're sending it to the user's "Home" room. For sending an extension request to the shop room you have to specify the Shop room as the third parameter of the ExtensionRequest's constructor.

Hope this helps
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 25 Mar 2013, 12:22

Thanks for reply,
I am not changing the room variables of Shop room....
Actually I am changing the variables of Home room.... Since for each room variable (ex:Home1#m0_Map, Home2#m0_Map) I have got different maps assigned...
So the thing in brief is from Shop room I am trying to change variables of Home room and then joining the Home room.... :(
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Room variables update issue

Postby rjgtav » 25 Mar 2013, 12:35

Yes, I understand. But on the ExtensionRequest, you're sending it to the Home room, not to the Shop room which is the one that has the extension attached.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 25 Mar 2013, 12:40

Ok.... Sorry, I will correct it....
But I am really very poor in java..... So please help me out....
So if I send the Shop room as 3rd parameter.... How do it update the variables of Home room????
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Room variables update issue

Postby rjgtav » 25 Mar 2013, 21:47

Hi,

On your server-side extension you're already updating the RoomVariables of the room which name is the one sent from the client, the roomName property, so you simply need to send the room's name and the extension will do the job.

Hope this helps
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 26 Mar 2013, 09:18

Thanks a lot rjgtav,

Now the room variables are updated fine... But still not getting the updated map loaded!!!
Getting this error on server-side logs!!?

[OpenSpace]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.IllegalArgumentException
Message: SFSObject requires a non-null value! If you need to add a null use the putNull() method.
Description: An unexpected exception occurred while the OpenSpace Core Extension executed command path
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.entities.data.SFSObject.putObj(SFSObject.java:679)
com.smartfoxserver.v2.entities.data.SFSObject.putUtfString(SFSObject.java:640)
com.smartfoxserver.openspace.handlers.OSRequestHandler.sendErrorToUser(OSRequestHandler.java:149)
com.smartfoxserver.openspace.handlers.OSRequestHandler.handleClientRequest(OSRequestHandler.java:129)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:192)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:137)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Please help...
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Room variables update issue

Postby Bax » 26 Mar 2013, 09:54

The error you get is due to a small bug when the server is trying to communicate to the client that an error occurred while running a pathfinding routine on the map.
In other words, when you load the new map an error related to the pathfinding occurs. Then the extension tries to let the client know about this error, and that's where the bug kicks in. But the problem is not the bug, it's the pathfinding error.

Now, before that stack trace is printed in the SFS log, you should be able to read a WARN log message which explains what is going on. Can you report it? I have the feeling that you are not loading the new map in the proper way. In fact when a map is loaded, the OpenSpace extension also creates the required data structures to perform the pathfinding. My idea is that changing the room variables on the same Room is wrong. You should create a new Room with the new variables, so that the loading process is correct.
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 26 Mar 2013, 10:43

Thanks Bax,
The error came only once... I mean I am not able to reproduce the error....
I think I am loading the map in a correct manner since I am using the same procedure for all maps loading...

But now I am not getting any errors on both sides.... Still the problem persists!!!
I am trying to avoid creating more rooms....

The thing is once the room variables are updated if I load some other map and from there if I again load the room who's variable I have changed, It works perfect--
loading is fine even I can see the updated map.....

But if I change the room variables and then if I directly load that map..... the problem occurs!!!???

Any other solutions rather than creating a new room??? If not then update room variables is a concept which cannot be used right?
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Room variables update issue

Postby Madhav » 26 Mar 2013, 10:49

The WARN log message you asked is---->
[OpenSpace] Pathfinding error: user Madhav [29] is not in the room for which the path has been requested
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Room variables update issue

Postby Bax » 26 Mar 2013, 10:51

I don't get why you don't like to create a new room... the new one is created, the user joins it leaving the previous one, which gets destroyed. no issues at all and the process is more straightforward.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 3 guests