polling

Most efficient way to tail/poll a log file in Java [duplicate]

你离开我真会死。 提交于 2019-12-03 03:46:56
This question already has answers here : In Java, what is the best/safest pattern for monitoring a file being appended to? (7 answers) There are many approaches, one could use create a Program and just call the Unix tail command, however the problem with this is that the process must be installed on a Unix machine with tail installed. The other option is to just read the file, line by line until there are no more lines, sleep for a period of time and then try to read the next line and repeat. The question is what/how do I go about polling a file which is actively being written to. AFAIK there

What is a RESTful way of monitoring a REST resource for changes?

不想你离开。 提交于 2019-12-03 03:03:02
问题 If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so? One idea I've had for doing so is by providing specific resources that will keep the connection open rather than returning immediately if the resource does not (yet) exist. For example, given the resource: /game/17/playerToMove a "GET" on this resource might tell me that it's my opponent's turn to move. Rather than continually polling this

Polling a Collection with Backbone.js

孤街醉人 提交于 2019-12-03 00:49:33
问题 I’m trying to keep a Backbone.js Collection up-to-date with what’s happening on the server. My code is similar to the following: var Comment = Backbone.Model.extend({}); var CommentCollection = Backbone.Collection.extend({ model: Comment }); var CommentView = Backbone.View.extend({ /* ... */ }); var CommentListView = Backbone.View.extend({ initialize: function () { _.bindAll(this, 'addOne', 'addAll'); this.collection.bind('add', this.addOne); this.collection.bind('refresh', this.addAll); },

Android: Polling a server with Retrofit

时光毁灭记忆、已成空白 提交于 2019-12-03 00:36:37
I'm building a 2 Player game on Android. The game works turnwise, so player 1 waits until player 2 made his input and vice versa. I have a webserver where I run an API with the Slim Framework. On the clients I use Retrofit. So on the clients I would like to poll my webserver (I know it's not the best approach) every X seconds to check whether there was an input from player 2 or not, if yes change UI (the gameboard). Dealing with Retrofit I came across RxJava. My problem is to figure out whether I need to use RxJava or not? If yes, are there any really simple examples for polling with retrofit?

Polling, Comet, WebSockets, etc

寵の児 提交于 2019-12-03 00:14:06
I'm needing to build in some pretty agressive "auto refresh" capabilities into a web application. It's kind of a photo gallery and the images are stored on AmazonS3 but the data about the images are stored in our own database. I've played around with polling the server and sending ajax calls to get the updated data. I'm really concerned about the load on the server(s) with this method. At times, the page would need to be updated every 15 to 30 seconds. I've been reading on Comet and I'm just not sold that this "hack" is a great idea. WebSockets would probably help but I'm concerned they are

Polling request for updating Backbone Models/Views

安稳与你 提交于 2019-12-02 21:59:10
I need to find a way to update a web App implemented with backbone . The use case will be the following: I have several Views, and each View, or maybe model/collection related to this view, needs to make different polling request to the server at different time for discovering some change. I am wondering what is the most general way to: 1) implement the Traditional Polling Request 2) implement the Long Polling Request 3) implement the HTML5 web socket P.S.: 1) The server is written in PHP. 2) For now I am looking for a solution without using HTML5 WebSockets because maybe with PHP is not so

When to use the POLLOUT event of the poll C function?

萝らか妹 提交于 2019-12-02 21:15:20
I wrote a small TCP servers with socket() + POLLIN poll() + recv() + send() , but I don't know when to use POLLOUT poll or select writefds to poll on writable event. Can anyone give me an example of the real usage of POLLOUT ? The usual pattern is to use non-blocking file descriptors with poll() like this: When getting ready to poll() , Always set POLLIN because you are always interested in reading what the other end of the socket has send you. Except if you have a large backlog of incoming data and you intentionally want to make the other end wait before sending more. Set POLLOUT only if you

How do I do realtime database polling in MySQL/PHP?

↘锁芯ラ 提交于 2019-12-02 19:52:09
I have a Ruby script which is constantly updating a MySQL database. I want to show the " mysql_num_rows() " in realtime. So as an entry is entered into the database by the Ruby script I want the PHP script to update its mysql_num_row() count in realtime. I tried using <meta http-equiv="refresh" content="5"> , but I don't think this is the best solution. Does any one have a better solution? Use JavaScript on the page to periodically make a call to the server and get some data. Using the jQuery library for cross-browser support of AJAX, you would simply do this: jQuery(function($){ setInterval

What is a RESTful way of monitoring a REST resource for changes?

南楼画角 提交于 2019-12-02 16:36:29
If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so? One idea I've had for doing so is by providing specific resources that will keep the connection open rather than returning immediately if the resource does not (yet) exist. For example, given the resource: /game/17/playerToMove a "GET" on this resource might tell me that it's my opponent's turn to move. Rather than continually polling this resource to find out when it's my turn to move, I might note the move number (say 5) and attempt to

VAADIN 7: What is the simplest way to refresh a Vaadin View in 5 minute intervals?

你说的曾经没有我的故事 提交于 2019-12-02 13:20:02
问题 I'm trying to implement an automatic refresh on a List of components in a Vaadin view. The list gets its contents from a database. I can refresh the list with a button, that is already implemented. However, I would like to know what is the simplest way to make it so, that this refresh event, that I already have, would automatically refresh in 5 minute (300 000 milliseconds) intervals? Here's what I tried and it keeps refreshing even after I exit the view so it doesn't really work. I'd like