PDA

View Full Version : How do I handle server push within ExtJS 4.2.2 app?



xjscrafter
2 Feb 2014, 11:47 PM
Getting started investigating server push to ExtJS apps, but I have a question about how to handle it on the ExtJS side.

My understanding is that with server push, ExtJS app might have no idea the server might push to it.

Is this the case, or do I need to do something to make my ExtJS app "server push aware", like making it listen or ready to get the pushed data?

I imagine server pushing some data, and ExtJS just gets it and handles the data.

But how does the server know where to push the data to? If there are 5 types of server push that at any time might go to an ExtJS app, how does the server know where each of those 5 pushes go to?

Sorry if I seem ignorant of how all this works, but I'm just getting started in this and am wondering how this stuff works with ExtJS.

nohuhu
3 Feb 2014, 2:45 PM
One approach is to use events for the server push. In one of my projects, I leveraged the Ext.direct.PollingProvider and built a server side framework that allowed to post either unicast or broadcast events. The client side part consisted of a singleton that registered on the PollingProvider, kept track of the subscription requests, etc., and posted incoming events on a custom event domain. The actual consumers of the event were Controllers listening on that domain and taking appropriate action upon firing an event.

The upside is that once the low level parts are in place, it's quite easy to work with the stuff. The downside is that it required considerate amount of work to be done on the server side as well, which probably is always going to be the case.

Regards,
Alex.

olecom
21 Oct 2014, 7:09 PM
The downside is that it required considerate amount of work to be done on the server side as well, which probably is always going to be the case.


Here is my take on that with only XHR on client and node.js+connectjs (auth and sessions) on server sides which is quite small. Backend has session status management, broadcast and singlecast internal api calls.

https://github.com/suprojs/supro/wiki/wes:-Server-Sent-Events-(SSE),-Server-Push-for-SUPRO-under-Node.JS-and-ExtJS

(https://github.com/suprojs/supro/wiki/wes:-Server-Sent-Events-(SSE),-Server-Push-for-SUPRO-under-Node.JS-and-ExtJS)