Hi, are you around Arfff? You gave me some advice about using a long lived connection as a backchannel, would be grateful if you could get in touch with me as I would like to duscuss this further and ask your advice.
Rather than setting up an HTTP connection, sending a message, and then receiving a reply, is there a way to keep the connection open, so that further messages can be received without anything else being sent?
I need this to work with standard HTTP, or with sockets, so that all java phones are capable of it.
I am implementing a turn-based game, but I don't want the midlet to have to keep polling to see if new moves have been made by the opponent, I want them to come in to the midlet when they are made. Any ideas?
You can use a long-lived HTTP request to stream messages from the server back to the client. You'll need to use a separate request channel to send future requests though which ought to work but doesn't due to the thread/network problems on the handsets.
For the 'backchannel':
1) connect to a servlet from the handset to be used for messages from server-> client
2) servlet sets contentLength to something 'large'
3) servlet permanently stays connected to handset for sending messages from game
4) messages from game get sent across connection and flush()ed
5) handset (in background thread) reads byte by byte and needs to know when a complete message has come across.