Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

Communicating between two servers

Hi,
There is a url say A When my java application makes a post request to A with data {"text" : "Enter email ids"}
A is configured to send a response json like {"message successfully delivered"}.
Now when i hit A with that post data this actually asks a user (its a chat app but the problem does not concern that) to enter email ids. and when the user enters a email id in that chat app it is configured to send it to a particular url... (this url can be any custom url which i can define).
So suppose in my java application i set up a server to listen on localhost:8080/sendmessage
And so the chatapp can send the email ids sent by user and post it to the above url. This can be configured in the chat application.

And when my application receives the email id's i can do further processing....

But the problem is if the user does not enter anything withing 15 seconds of receiving the message then My application should detect that and send another message to the user {"text" : "No input. Please enter email ids"}
How can i do this ? This is the first time i have encountered such a problem  have no idea about it.. i hope i explained the problem clearly.

Its mostly like listening for a post request and if there is no hit within 15seconds then i hit the url with message {"text": "no input. Please enter email ids"} ie send this message to chat app. otherwise i perform some action like validating email address etc....
i can think of having some function like listen(/sendmessage, listener, 15)  where /sendmessage is a mapping where my server is listening for a post request.

Thanks
SOLUTION
Avatar of Carl Dula
Carl Dula
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rohit Bajaj

ASKER

There is no javascript here...
Its only get and post request sending json data with each other..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You don't need much in the way of javascript. Take a look at:

http://www.w3schools.com/jsref/met_win_settimeout.asp