Git Product home page Git Product logo

eventsource's Issues

Session locking

Somewhere inside this library some session locking seems to be occuring. Test script:

<?php
include __DIR__ . '/../protected/vendor/autoload.php';
ob_end_flush();
$server = new \Hoa\Eventsource\Server();
$i = 0;

while($i < 20) {
    $i++;
    $server->send(time(), $i);
    sleep(1);
}

This code should send 20 messages over 20 seconds. When calling this from a server in 2 browser tabs, 1 stays empty until all 20 messages have appeared in the other, after which it starts displaying messages.
If I instead open 1 tab in private browsing mode both tabs show the messages simultaneously.

Client does not accept text/event-stream

Hi,

I get this error message when trying your sample code:

Uncaught Hoa\Eventsource\Server::__construct(): (1) Client does not accept text/event-stream. in /app/public/wp-content/plugins/helpie-chat/vendor/hoa/eventsource/Server.php at line 114.

And the Eventsource works in a simple way when trying without any library like yours.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Properly disable output buffering.

We had some issues with a server which had output_buffering enabled via php.ini.
Debugging was made harder due to the fact that the Server creates an output buffer in its constructor, which is a side effect..

Since output_get_level will reliably tell us if output buffering is enabled, it would be nice to just throw an exception in that case:

    public function __construct($verifyHeaders = true)
    {
        if (true === $verifyHeaders && true === headers_sent($file, $line)) {
            throw new Exception(
                'Headers already sent in %s at line %d, cannot send data ' .
                'to client correctly.',
                0,
                [$file, $line]
            );
        }
        if(ob_get_level() > 0) { 
            throw new Exception("Output buffering is active");
        }

Alternatively output buffering could be disabled:

  while (@ob_end_flush());

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

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.