PDA

View Full Version : Multiple login event handlers



saciform
10-10-2011, 07:44 PM
Hi Teresa,

Please help me with this one:
I have 2 different extensions for 2 different games with 2 different login handlers (using 2 different web services to log them in).
They need to be deployed on the same server.
How should i configure the Login handlers in order to be able to log users for each extension separately?

Thanks

tcarr
10-10-2011, 08:39 PM
The way I would approach this is to use the optional EsObject that can be attached to the LoginRequest. In your client, it will look something like this:


var lr:LoginRequest = new LoginRequest();
var esob:EsObject = new EsObject();
esob.setBoolean("fb", true);
lr.esObject = esob;
_es.engine.send(lr);


Then in the LoginEventHandlers' executeLogin, you check that esob. It has to specify which of the allowed web services it is using, or you fail the login. If it specifies a web service other than the one for this LoginEventHandler, you return ChainAction.OkAndContinue. If it specifies the one this LoginEventHandler processes, then you process the login. Make sure that you fail any logins that don't specify one of the allowed web services.

Here's how to get the EsObject in the LoginEventHandler:


EsObjectRO loginParamsRO = context.getRequestParameters();
EsObject loginParams = new EsObject();
if (loginParamsRO != null) {
loginParams.addAll(loginParamsRO);
}


See the FacebookConnect example for more info.

tcarr
10-10-2011, 08:59 PM
Since your different login event handlers are for different games, I would have the login event handlers set a user server variable on each successful login, indicating which one was used, and then the game plugins check for that user server variable value, in the userEnter method. This would prevent a hacked client from logging in with one web service and then playing both games.