Problem in sending and receiving messages in android application

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Jan 3, 2015 9:43:51 PM via Website

Hi all,

I have designed an android application which sends a message to a server and receive a response, sending and receiving is done using eneter messaging framework , you can google it , I can not add its url.

send a message to a server and when the response is received, I want to save the coming information in a variable. The problem is : when I tried to save it in a variable, it seems that it does not wait for response to receive.

Here is the code for sending and receiving message :

 private IDuplexTypedMessageSender<Position, RequestForPosition> mySender; 

position and RequestForPosition is classes for send and receive :

the code for sending :

// Create the request message.
     RequestForPosition aRequestMsg = new RequestForPosition();
     aRequestMsg.Text = "Get Current Position of " + ":" + TagNameAndIDs ;

     // Send the request message.
     catch (Exception err)
         EneterTrace.error("Sending the message failed.", err);

the code for receiving :

private void onResponseReceived(Object sender, final TypedResponseReceivedEventArgs<Position> e)
 { Runnable()
             public void run()
                          currentPos.PlaceName = e.getResponseMessage().PlaceName; 
                 currentPos.x = e.getResponseMessage().x ; 
                 currentPos.y = e.getResponseMessage().y ; 
                 currentPos.z = e.getResponseMessage().z ; 


after I send request and in the second line of code I print the currentPos variable, it does not hold the value that is returned from the server, but when I print it in the response function it is ok.
please help me, I tried to solve this problem for three weeks ago with no results :(

thanks in advance.