Page 1 of 1

User object no longer available on user lost

Posted: 29 Oct 2007, 14:22
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...

Posted: 29 Oct 2007, 16:25
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

Posted: 30 Oct 2007, 09:37
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?

Posted: 30 Oct 2007, 10:07
by jalava
Edit: nvm, my bad.