Good day. Explain, please.

Here in the php script configured for an infinite loop, I first call the messages.GetLongPollServer method, then I join the longpoll, the page loads up to 25 seconds or until it receives an event.

To check I send a message, everything comes, everything works. then I call messages.GetLongPollHistory. It works too. There further there is an event handling in a script and again a cycle on the new.

My question is: you need to handle all the events, but what to do if the message came during the processing of another event, because it does not get into the long poll connection and I cannot get it and process it, what should I do in this case?

Here is the algorithm:

while(!$stop) {

  1. messages.getLongPollServer
  2. Подключение к long poll : http://{$server}?act=a_check&key={$key}&ts={$ts}&wait=25&mode=2 (here the page loads 25 seconds, or until the event arrives)
  3. messages.getLongPollHistory
  4. handle events
  5. check for a stop command

}

    1 answer 1

    When you pass the ts parameter, you specify the limit after which you want to return messages.

    For example, the result of a request to the LongPoll server: { ts: 934518069, updates: [] }

    It is necessary to save ts to a variable and pass it on the next request. In the situation you described, the VC will understand that the last event processed by the program is 934518069 and you need to return the events that occurred after it.