Server code Pressing data in a client browser While the current thread is busy Comet (programming)

I am writing one simple web page with a bunch of text fields and a control button. Now that the user has finished editing the values ​​in these text fields, the user must click a button, and this button calls an intensive algorithm with an intensive process on the server side based on data received from the client (text fields)

And it may take up to 30-45 minutes to complete the whole operation, so the current thread is still inside the function of the button click event handler.

This background task provides only one event, and the web page subscribes to it to receive some textual data after each processing step.

I wandered if there is any way so that I can constantly update information about what is the current progress in this background task. I have a div element to print current status information

So, I am looking for some kind of reverse mechanism, then "get" and "post".

I have read several articles on comets (programming), but I cannot find an easy or definitive answer

Thank you in advance

+3
source share
4 answers

Perhaps the easiest way is to send the job and return the identifier via a direct POST message. This identifier corresponds to long server-side operation.

HTTP, .. . () 30 .

, . , /. , 30/45 , .

+2

"Comet" (aka Ajax-Push reverse-Ajax). , "" - , , . Ajax , , , , ( webapp, ..). , StackOverflow , , .

, , , , , id , . , ajax , , , , , Ajax . , ajax div , .

+2

, . , , , , . - , 30-45 , . , , , , , - (, ).

+1

:

  • Comet ( )
  • If any delay is acceptable (for example, the system notifies you 1 minute after the completion of the process), then the AJAX timers (polling) are yours.

Take a look at three examples of both methods based on ItsNat framework:

Sorry, this is Java.

+1
source

Source: https://habr.com/ru/post/1717866/


All Articles