GWT Servlet-based Notification (Server Event Bus)

2019-07-21 21:48发布

Can anyone think of a good way to allow the server to notify the client based upon server processing? For example, consider the following events:

  1. A user requests a deletion of data, however, due to it's long-running time, we kick it off to a queue.
  2. The client receives a "Yes we completed your transaction successfully".
  3. The server deletes the item and now wants to update any local structures any clients may be using (I'd also like to notify the user).

I know this can be done by client-side polling. Is there a event bus type way to do this? Any suggestions are welcome, but please keep in mind I am using GWT with App Engine.

2条回答
爷的心禁止访问
2楼-- · 2019-07-21 22:12

The standard AJAX interaction is that the client sends requests to the server and expects some sort of response back fairly quickly.

In order for the server to initiate a request to the client, you will need to use WebSockets, and experimental HTML5 feature currently only supported by Chrome.

Or, to simulate this kind of interaction, you can use Comet (long-polling), made available in GWT by the rocket-gwt project.

查看更多
够拽才男人
3楼-- · 2019-07-21 22:19

You want server events for GWT? Have a look at GwtEventService (they couldn't have chosen a better name): http://code.google.com/p/gwteventservice/wiki/StartPage

Of course, it uses a Comet implementation, but you can't do any different when using HTTP, the client always initiates the communication. Request, response.

查看更多
登录 后发表回答