The communication of the server-side to the client-side
- Lately,I use the JSON-RPC-Java to communicate between the client-side
and the server-side in my project. I know,the principle of this RPC
protocol is : the client sends a request to the server,the server handle
the request ,and then responses to this specified request; but now ,I
want to do that ,if the server changed,I want the client know this
I also thought about using the timer in the client to send request to
the server periodically,but if there were a lot of big numbers waiting
for send,the cost is great.So I don't know what should to do ?
- Unless you can open a socket connection from the client to the server
which stays open, there is no way for the server to push the data as
it is generated. You will have to use polling with a timer, say every
2 seconds you make a request to the server and the server sends the data.
To lower the number of requests, you could have the server keep the
connection open and wait for the client requestto timeout if there is
no data to be sent. The client would know to just send another request
after the. This way the client would get data pretty much the moment
the server generates it. There is only a little lack when rerequesting.