View Full Version : Need help about Ajax Queuing
thethanghn
2 Dec 2008, 12:10 AM
HI everyone,
I'm newbie to Ext JS and this is my first post :)
I'm searching through all docs but cannot found any Ext widget supports my purpose.
I've created a mini text base game that a user would do many actions. And every action was sent by AJAX request. But the problems is those actions was submitted and received at another end in unexpected order. I'll try to append a counter to each Ajax call but it didnt help.
Does ExtJS support any kinds of AJAX Call Queue and verification process?
Thanks.
Animal
2 Dec 2008, 1:13 AM
Not natively. An AjaxQueue class would be an interesting addition though. You could push Ext.Ajax.request parameter objects onto its queue for sequential processing.
It shouldn't be too difficult to implement.
thethanghn
2 Dec 2008, 1:34 AM
Honestly, simple push and shift doesnt work for me.
The situation is:
======================================================
CLIENT 1 -------------> SERVER ----------------> CLIENT 2
Json array Json array
=======================================================
And my flow is alike:
# Client 1:
- An json object sent to QueueManager
- If it has pending request, push the object into a queue
- Once the request done, QueueManager send all the queue as an JSON array (not each json object) to server
--> the issue is: how to maintain the object order and verify if one is missing (causes the game to stop)
# Server: doesnt do anything special
# Client 2:
- Receive the queue
- Verify whether it is in correct order
- If some is missing, request an resent from client 1, client 1 must have the ability to retrieve and sent exactly json object, so that I suppose the queue must be an MixedCollection extension
- If things allright, process each object in the queue
Is there any QueueManager like that?
you can go and take a look at my mini game at: http://infomap.vn/dueling/default.aspx
Animal
2 Dec 2008, 2:02 AM
Obviously the QueueManager would have to perform the processing of the next queued request in its callback function to maintain order. With Ajax being asynchronous.
TopKatz
2 Dec 2008, 5:12 AM
Why not just build this que into your server side logic? If you gave each request a time stamp and sequence number of some sort you would know how to order them on the server. The sequence would tell you the individual client order, and the time stamp would tell you the order in relation to other players.
hendricd
2 Dec 2008, 6:09 AM
ext-basex has had named-priority queuing built in for some time. (see my sig for the ux link)
thethanghn
2 Dec 2008, 6:37 AM
Why not just build this que into your server side logic? If you gave each request a time stamp and sequence number of some sort you would know how to order them on the server. The sequence would tell you the individual client order, and the time stamp would tell you the order in relation to other players.
Thanks for your idea, I had implemented some kind of server side queue with help of JsonExtSerializer.
At client side, I'm using 2 MixedCollection as a queue, one act as a active queue, the other act as temporariry store while the active queue being in process. but it still has mysterious bug that I guess it caused by browser.
Besides, do u know any ways that server can broadcast the change to all client connect to it? So that client's no longer need to request periodically
TopKatz
2 Dec 2008, 6:46 AM
If you want to maintain comm, you would need to poll from the client.
Another way to keep client server comm going is in the response text of a ajax call, you could easly include some root information that helps game play along.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.