GithubHelp home page GithubHelp logo

panique / php-long-polling Goto Github PK

View Code? Open in Web Editor NEW
424.0 424.0 132.0 11 KB

An extremely simple example of a "real-time" self-updating page using long-polling.

JavaScript 28.96% PHP 62.74% HTML 8.30%

php-long-polling's People

Contributors

bitdeli-chef avatar grahamcampbell avatar panique avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-long-polling's Issues

Just a question

Hi!
Can someone help me?
When data.txt change I want to reload the client.html page (instead of changing the "response" div content).

I've tryed also something like this (so i can use php to reload page or other things)

$('#response').html(" ");

but the string "hello world" is never displayed (of course, i've renamed the client.html in client.php)

Any help is really appreciated.

realtime with php

Hi,

I am also looking for something in php to use websocket, are you find something useful?

" I'm currently experimenting with lighttpd, NGINX and appserver.io to find a better solution. "

overloading apache2

have you ever experienced apache overloading or being non responsive?
it feels like apache or php just continue to run even if the client already closed the browser.

thanks in advance

Can't refresh page twice when session.auto_start set 1 in php.ini

Tested system: ubuntu/arch linux + apache

step:
copy index.html to client.php ( only php file can reproduce )

I can't refresh client/client.php at second time when session.auto_start=1 in php.ini

I resolve it after add session_write_close() or session_commit() in server.php

relative issue:
http://stackoverflow.com/questions/13213396/no-reply-when-using-flush-session-cookies-and-long-execution-time

I'm glad you read my report. Sorry for my poor English.

Problems with database binding.

It was necessary to chat about this technology, everything seems to be usually updated on the example of the file, but how to update the query?
`set_time_limit(0);
while (true) {
$data_source_file = R::findLast('messages', 'dialog = ? ',array($_GET['getmess']));
$last_ajax_call = isset($_GET['timestamp']) ? (int)$_GET['timestamp'] : null;
clearstatcache();
$last_change_in_data_file = $data_source_file->date;
if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) {
$data = $data_source_file->message;
$result = array(
'data_from_file' => $data,
'timestamp' => $last_change_in_data_file
);
$json = json_encode($result);
echo $json;
break;

} else {
    sleep(1);
    continue;
}

}`

Well, roughly, the date of the last message looks like this $data_source_file->date;

The example not working in case of the client files (index.html, client.js) run directly by clicking on them.

I am using wamp server to run your example. If I open your example by: enter 127.0.0.1, then go to Your Projects > php-ajax-long-polling-master, your example run effectly. But if I click on index.html directly to open it on browser, the example not working. Are there anyway to solve this problem? Because I'm using jquery mobile and phonegap, my website files are on client, not on server. Look forward to hear from you. Thank you!

Just a question

Since you are sending the previous modification time in every Ajax request but the first, why not have the PHP code echo the message, then die()?

If changes are missed, you could put the sleep() call in the code that writes the file content rather than in your loop.

Keep alive

I am using this teqnique on a dashboard, running on an ipad.

Do you have a sugestion to how the script can reconnect when network connection is disconnected, and then eventually reconnected.

Claus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.