Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha Touch: Implementing Polling

I'm writing a mobile chat client for Microsoft Lync using Sencha Touch.

On the server side I'm using the JSONP-enabled WCF service from the lyncwidget codeplex project (http://lyncwidget.codeplex.com) Upon being called, the WCF service returns any messages that were queued on the server as JSON data.

The idea is that the client(s) poll the service regularly to retrieve any new messages.

I want to implement the polling behaviour directly in my Store's Proxy, if this is possible. So in the "ChatMessagesStore".

Any advice on how to implement this in a neat way?

Thanks.

ps: I'm a newbie at Sencha Touch.

like image 212
Thomas Stock Avatar asked Jun 17 '26 07:06

Thomas Stock


1 Answers

The best would be to extend the Ext.data.ScriptTagProxy class. Then have a property inside called "pool-interval" and a method that would call the sync() function and it self. Example:

makeRequest(){
  this.sync();
  setTimeout("this.makeRequest()",pool-interval);
};

This way if you have multiple stores with proxy like this you wouldn't have to bother with setting multiple setInterval calls and the need to change them when you change the store's name.

like image 135
ilija139 Avatar answered Jun 20 '26 09:06

ilija139



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!