通信客户端-服务器-客户端 [英] Communication client-server-client
问题描述
我对客户端和服务器之间的通信有疑问.
I have a question about the Communication between a client and a server.
我想创建一个可以执行以下操作的GWT应用程序:
I would like to create a GWT application that can do the following:
客户端A向服务器触发事件,而服务器依次向客户端B触发事件. 在这里,客户端B必须能够一直收听事件.
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.
我想向连接的客户端B实时发送一些数据很少的事件. 那可能吗?如果是的话,我该怎么办?
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?
谢谢
推荐答案
客户端B必须始终能够收听事件.
Here the client B has to be able to listen to the event all the time.
要让客户端等待数据,如果目标JS运行时确实支持,则可以使用Comet [1](HTTP请求长期存在)或WebSockets [2].
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 /
这篇关于通信客户端-服务器-客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!