Login problem in Java extension
Posted: 05 Oct 2007, 16:44
Hi,
I've never wrote java extension before. Everything was written in actionscript. Then I started to port my extension to java and I got error when I try to do custom login.
Here is the code:
After call of "canLogin" server troughs this exception.
BTW, I am running server version 1.5.9
I've never wrote java extension before. Everything was written in actionscript. Then I started to port my extension to java and I got error when I try to do custom login.
Here is the code:
Code: Select all
if (ieo.getEventName() == "loginRequest") {
// Check login name
String nick = ieo.getParam("nick");
String pass = ieo.getParam("pass");
SocketChannel chan = (SocketChannel) ieo.getObject("chan");
JSONObject oResponse = new JSONObject();
// User object
User newUser = null;
// Retrive user params from db (web service)
DataRow userParams = dbLoginRequest(nick, pass);
try {
// PROBLEM IS HERE
newUser = extHelper.canLogin(nick, pass, chan, currZone.getName());
newUser.setVariable("uid", userParams.getItem("user_id"), UserVariable.TYPE_NUMBER);
oResponse.put("_cmd", "logOK");
oResponse.put("id", String.valueOf(newUser.getUserId()));
oResponse.put("user", userParams);
} catch (LoginException le) {
this.trace(le.getMessage());
oResponse.put("_cmd", "logKO");
oResponse.put("err", "Could not login user: " + nick);
isError = true;
}
}Code: Select all
java.lang.NullPointerException
at cpi.extPlayground.handleInternalEvent(extPlayground.java:171)
at it.gotoandplay.smartfoxserver.controllers.MessageHandler.dispatchEvent(MessageHandler.java:141)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.handleLoginRequest(SystemHandler.java:406)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.processEvent(SystemHandler.java:174)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.run(SystemHandler.java:122)
at java.lang.Thread.run(Thread.java:613)