Getting user details when overriding methods

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

Moderators: Bax, Lapo

Getting user details when overriding methods

Postby gwills » 13 Nov 2011, 22:41

I'm sure there is an easy way to do this, basically I am trying to override the loadInventoryData and update the inventory results based on the current user.

I know when I extend the API by using addRequestHandler the sender is sent as a a parameter in handleClientRequest but I am wondering how I can get this user info inside the following:

@Override
public String loadInventoryData(String inventoryId)
{
}

Sorry if this is documented somewhere but I have looked and haven't found how to do this.
gwills
 
Posts: 5
Joined: 27 Oct 2011, 18:06

Postby Bax » 14 Nov 2011, 09:28

You can't change the number of parameters passed to an overridden method. Maybe you can save the data you need in a global variable and then access it from within the overridden method.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3847
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby gwills » 24 Nov 2011, 10:03

But is the Current User not accessible as a global variable already somewhere?

I already have some information stored in the session for the user from a previous request and I am just trying to get access to this session info in the loadInventoryData method. I am sure all I am missing is the correct syntax here.

@Override
public String loadInventoryData(String inventoryId)
{
//Get Current User\Session

//Use the user info to return subset of inventory items
}
gwills
 
Posts: 5
Joined: 27 Oct 2011, 18:06

Postby Bax » 25 Nov 2011, 13:17

In that method there's no reference to the user who sent the request, I'm sorry.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3847
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby gwills » 28 Nov 2011, 09:35

Does anyone have any recommendations on how to achieve this. If it is not possible to filter inventory on the server side I could do it i guess on the client side, but i am trying to avoid downloading the entire inventory as a user may only have access to a small subset.
gwills
 
Posts: 5
Joined: 27 Oct 2011, 18:06

Postby Bax » 28 Nov 2011, 20:30

Why don't you override getInventoryItemsList method of the OpenSpace Extension? This allows you to filter the inventory items based on the requester and other custom parameters BEFORE sending them to the client. Check the API for details.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3847
Joined: 29 Mar 2005, 09:50
Location: Italy


Return to OpenSpace v2 discussions and help

Who is online

Users browsing this forum: No registered users and 2 guests