Well, the results can be returned in any order undefined, they are asynchronous and prone to the vagaries of the Internet and servers.
What you can do is solve the problem just like TCP over UDP. You are using sequence identifiers.
Keep the sequence ID and increment it every time you submit a request. When requests are returned, check them in order and process them only as they arrive. Keep a list of what returned with the data in order, and you have a regular fire to check this list after each update. When the first is expected, it should process the entire list before the first break.
Mention that you may lose the request, so the appropriate timeout before you ignore this sequence identifier will be fine.
Orbling
source share