Singular problem in ConnectionRequest object

20 views
Skip to first unread message

dario...@gmail.com

unread,
May 25, 2016, 3:48:12 AM5/25/16
to CodenameOne Discussions
Hi,
I have e singular problem in ConnectionRequest:

The follow code send a login request to server and work fine, but once authenticated if I stop and run the application another time, in the next login request allow me to access and return the correct json even if I wrong the password.

It's very strange behavior, could it be a cache problem?

ConnectionRequest cr = new ConnectionRequest("http://www.domain.com/rest/user/login.json");

cr.addResponseListener(new ActionListener<NetworkEvent>() {

public void actionPerformed(NetworkEvent evt) {

try {

//Log.p(evt.getMessage(), Log.DEBUG);

Map<String, Object> result = null;

result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(cr.getResponseData()), "UTF-8"));

Map<String, Object> ret = (Map<String, Object>)result.get("ret");

if ("true".equals(((Map)ret).get("success"))) {

Log.p("connected", Log.DEBUG);

//return (java.util.List<Map<String, Object>>)response.get("listings");

set(ViewInterface.PROPERTY_MSG, "ok");

((UserController)that).profile();

} else {

Log.p((String) ((Map)ret).get("message"), Log.DEBUG);

set(ViewInterface.PROPERTY_MSG, ((Map)ret).get("message"));

((UserController)that).login();

}

} catch (Exception e) {

set(ViewInterface.PROPERTY_MSG, e.getMessage());

Log.e(e);

}

}

});

cr.setPost(true);

cr.addArgument("data[User][email]", username);

cr.addArgument("data[User][password]", password);

NetworkManager.getInstance().addToQueue(cr);

Shai Almog

unread,
May 26, 2016, 12:16:45 AM5/26/16
to CodenameOne Discussions, dario...@gmail.com
Hi,
is this happening on the simulator or only on the device?
You can reproduce a background behavior by using the suspend/resume functionality of the simulator and also track the incoming/outgoing network calls vial the network monitor tool.
Reply all
Reply to author
Forward
0 new messages