polling

Detect If Browser Tab Has Focus

佐手、 提交于 2019-11-26 08:51:16
问题 Is there a reliable cross-browser way to detect that a tab has focus. The scenario is that we have an application that polls regularly for stock prices, and if the page doesn\'t have focus we could stop the polling and save everyone the traffic noise, especially as people are fans of opening several tabs with different portfolios. Is window.onblur and window.onfocus an option for this? 回答1: Yes, window.onfocus and window.onblur should work for your scenario: http://www.thefutureoftheweb.com

How does push notification technology work on Android?

廉价感情. 提交于 2019-11-26 07:54:14
问题 How has Google implemented their push notification feature? Does it work through polling done by a service running in the background or in a different way? 回答1: From what I've heard during an Android developers conference in Israel: There is simply a TCP socket waiting in accept mode on a cloud Google server. The TCP connection had been initiated by the Google Play application. That's why Google Play must be installed on the device for making Google Cloud Messaging (GCM) (formerly Android

Server polling with JavaScript

青春壹個敷衍的年華 提交于 2019-11-26 04:45:24
问题 What is best practise for polling server with JavaScript for application that needs to refresh data very rapidly? I\'m using jQuery for front-end and Java Spring Framework for backend. Example of refreshed data could be list of items that are getting updated very rapidly (every 1 second). 回答1: You may want to use jQuery's Ajax functions to poll the server every second or so. Then the server can respond with instructions to the browser in near real-time. You can also consider long polling

Using poll function with buffered streams

你。 提交于 2019-11-26 02:14:55
问题 I am trying to implement a client-server type of communication system using the poll function in C. The flow is as follows: Main program forks a sub-process Child process calls the exec function to execute some_binary Parent and child send messages to each other alternately, each message that is sent depends on the last message received. I tried to implement this using poll , but ran into problems because the child process buffers its output, causing my poll calls to timeout. Here\'s my code:

jQuery, simple polling example

旧城冷巷雨未停 提交于 2019-11-26 00:50:37
问题 I\'m learning jQuery, and I\'m trying to find a simple code example that will poll an API for a condition. (ie, request a webpage every few seconds and process the results) I\'m familiar with how to do AJAX in jQuery, I just can\'t seem to find the \"proper\" way of getting it to execute on a \"timer\". 回答1: function doPoll(){ $.post('ajax/test.html', function(data) { alert(data); // process results here setTimeout(doPoll,5000); }); } 回答2: Here's a helpful article on long polling (long-held

Detect If Browser Tab Has Focus

心已入冬 提交于 2019-11-25 16:58:28
Is there a reliable cross-browser way to detect that a tab has focus. The scenario is that we have an application that polls regularly for stock prices, and if the page doesn't have focus we could stop the polling and save everyone the traffic noise, especially as people are fans of opening several tabs with different portfolios. Is window.onblur and window.onfocus an option for this? Ryan Wright Yes, window.onfocus and window.onblur should work for your scenario: http://www.thefutureoftheweb.com/blog/detect-browser-window-focus Important Edit: This answer is outdated. Since writing it, the