@DirectPollMethod(event = "poll")
public String handleMessagePoll(Map<String,String> parameters) {
assert parameters != null;
Date now = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(
"dd/MM/yyyy 'at' hh:mm: ss");
System.out.println("Successfully polled at: " + formatter.format(now));
return "Successfully polled at: " + formatter.format(now);
}
JS code:
var pollingProvider = Ext.Direct.addProvider({
type: 'polling',
interval: 5000,
url: Ext.app.POLLING_URLS.poll,
id : 'poll1',
listeners: {
data: function(provider, event) {
Ext.log( 'poll');
updateMain('<i>' + event.data + '</i>');
getChartData(); // Receives json object from controller class to plot a chart
pollingProvider.disconnect();
}
}
});
pollingProvider.connect();
The problem I'm facing is the polling code (with the chart code) is getting sleep for 20 secs.
Instead I want the polling to be displayed till the chart data is received by the client. And as soon as chart data is received, close the polling also.
Please help me. I am not getting any clue to intergrate the server functionality with the polling technique. I am using Ext.Direct with DJN.