User object no longer available on user lost

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
jalava
Posts: 40
Joined: 03 Sep 2007, 12:23

User object no longer available on user lost

Post by jalava »

When extensions get EVENT_USER_LOST, uid contains id of user that is no longer available via helper.getUserById(Integer.parseInt(sfsUserId));

This causes problem because when user is lost, we need to have access to the users properties map to fetch real uid which we are using to log user out of the 3rd party authentication servers etc.

This problem only seems to occur on Room level extensions.

Example code from room level extension

Code: Select all

		if(evtName.equals(InternalEventObject.EVENT_USER_EXIT) ||
				evtName.equals(InternalEventObject.EVENT_USER_LOST))
		{
			String sfsUserId = ieo.getParam("uid");
			if(sfsUserId == null || sfsUserId.isEmpty())
			{
				return;
			}
			
			User user = helper.getUserById(Integer.parseInt(sfsUserId));
			Long fgpuserId = (Long)user.properties.get("uid");
			FGPUser zUser = ZoneCache.getInstance().getUserCache(zone.getName()).getUser(fgpuserId);			
                        // Clean up calls using our internal user object starts here
		} 
Any ideas? I really would not like to setup another singleton hashmap for mapping between sfs uid and our own uids...
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

If you use SmartFoxServer 1.5.8c or the latest 1.5.9 the User object is passed in the event.

in Java you get it by using:

Code: Select all

User u = (User) ieo.getObject("user")
hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
jalava
Posts: 40
Joined: 03 Sep 2007, 12:23

Post by jalava »

Ok, I tried that, however, it seems that something strange happens when I close my client:

WARN - Failed to locate user with id:null

this comes just before I get the EVENT_USER_LOST in my room extension.

Any reason why user could be missing on this case?
jalava
Posts: 40
Joined: 03 Sep 2007, 12:23

Post by jalava »

Edit: nvm, my bad.
Post Reply