Communication client-server-client

2019-08-06 04:56发布

问题:

I have a question about the Communication between a client and a server.

I would like to create a GWT application that can do the following:

The client A fires an event to the server and the server in his turn fire an event to the client B. Here the client B has to be able to listen to the event all the time.

I wanted to send some event with few data in real time to a connected client B. is that possible? and if yes how can I do that?

Thanks

回答1:

Here the client B has to be able to listen to the event all the time.

To let client wait for data, you can use Comet [1] (long lived HTTP requests) or WebSockets [2] if targetted JS runtime does support it.

[1] : http://code.google.com/p/gwt-comet/

[2] : http://code.google.com/p/gwt-ws/



回答2:

here is one exampleof course its possible for the communication between client and server you have to use Rpc(Remote Procedure call). you can send and recieve data as a serialized objects via rpc



回答3:

Just store the result of client's (A's) request in a Database. and write client side code to request the content from the db, process it in the server and give the result back to the client(in your case, client B)