Problem: return from one method when another method is called

M

Magne Bergfjord

Hi!

I have an http module which I intend to use in my application:

To connect to a server and send a request, there is a method like this in
the module:

public void sendRequest(String query){
....
}

When the server responds, it calls another method in the same class:

public void respons(String results){
....
}

I want to combine these two methods so that my application can use one
method looking something like this:

public String sendRequest(String xml){
....
}

which returns the results when the server calls the respons method. Is
this possible?

To summarize, the problem is to make one method return something when
another method is called. I guess there are some smart ways around this
problem, but I haven't found any yet. I hope there is some way to solve
this without changing the underlaying logic of the http module too much.

Magne Bergfjord
 
J

John

Magne said:
Hi!

I have an http module which I intend to use in my application:

To connect to a server and send a request, there is a method like this in
the module:

public void sendRequest(String query){
...
}

When the server responds, it calls another method in the same class:

public void respons(String results){
...
}

I want to combine these two methods so that my application can use one
method looking something like this:

public String sendRequest(String xml){
...
}

which returns the results when the server calls the respons method. Is
this possible?

To summarize, the problem is to make one method return something when
another method is called. I guess there are some smart ways around this
problem, but I haven't found any yet. I hope there is some way to solve
this without changing the underlaying logic of the http module too much.

Magne Bergfjord

public String getData(String input) {

//contact the server

//initialise a variable x that will be set by the server.

while(notset(x)) {

//sleep
}

//return x

}

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top