It is assumed that the client in java in GWT has already called the server (method call and server asynchronous response).

Can the server identify the clients accessing it and call the client on its own initiative (transfer data to it)?

Maybe I was looking badly on the web, but I got the impression that this was impossible.

  • You have almost the right impression. This is because HTTP has its own specifics. - cy6erGn0m

2 answers 2

The essence of the comet is that the client connects to the server, go through the request and the server starts to respond ... and everything answers and responds and does not finish the answer for a long, long time. You can even keep the connection open for ages. At the same time, the server at any time can add in response to something and the client will immediately receive a response (if the network works properly, of course), without delay (except network delay).

Since you are using GWT and Java on the server, it is logical to use GWT-comet . Actually, Getting Started .

To better understand the principle, read Ajax for Java developers: Write scalable Comet applications with Jetty and Direct Web Remoting . This article is designed for Jetty and does not describe the client side, but explains how Comet works.

  • Thank you so much ! I will study. - avp

This is possible. I see two ways.

  1. Poll server by timer.
  2. Leave an open connection. If necessary, send a response, which will be a set of commands for further work.
  • one
    The second is called comet. - cy6erGn0m
  • Thank ! With 1. everything is clear, and for obvious reasons it is not very interesting (I mean the case when the server responds to the request without delay). About 2. is not very clear. If possible, in more detail. The algorithm of the server method (s) is not clear. In continuing the discussion, I will supplement (edit, UPD ) the question. It is right ? - avp 6:49 pm
  • @avp Yes, that's right. - Nicolas Chabanovsky