here is an example of code that i write to make connection request. In this
example, i am sending a new password to the user when ever he forget it.
But i have realised that when request is sent to the server side
forget.php, the email is sent automatically but the readResponse method
takes too much time before displaying the Dialog, this is not a low
connection problem cause i have tested it with very hight speed connection
Can you tell what to do to make readResponse method be called once the
server side have done his job?
ConnectionRequest requette=new ConnectionRequest(){ Map data; @Override
protected void postResponse(){ String donnees=(String)data.get("reponse");
Dialog.show("", "An email has been sent to you on "+em+"\nPlease check it to
found out your password", "OK",null); } @Override protected void
readResponse(InputStream input)throws IOException{ JSONParser parser=new
JSONParser(); data=parser.parseJSON(new InputStreamReader(input)); } };
requette.setUrl(new ServerUrl().getServerUrl()+"/forget.php");
requette.setPost(true); requette.setTimeout(15000);
requette.addArgument("email", em); requette.setDisposeOnCompletion(new
LoadingDialog(new Form()));
NetworkManager.getInstance().addToQueueAndWait(requette);
here is an example of how the server side script "forget.php "fis looking like:
<?php include("connexion_base.php");
$email=mysql_escape_string($_POST["email"]);
$select=mysqli_query(connection(),"select * from users where email='$email'");
if($r=mysqli_fetch_array($select)){ $pw=$r["pw"]; mail($email,"foganbidi","Your
password is:\n$pw\n","From:foganbidi"); $sms.="Your password is:$pw"; }else{
mail($email,"[email protected]","The email you submited does not exist in our
database","From:foganbidi"); $sms.="The email you submited does not exist in
our database"; } $data=array("reponse"=>$sms);
header("Content-Type:application/json"); echo json_encode($data);
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/ff32e78d-f28e-4949-bb96-ce0d63d3a008%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.