Created
April 27, 2015 08:27
-
-
Save till/e7412234131e9c50ebec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// an attempt to read data from a local nginx pushstream setup | |
$this->client = new Client('http://vm.local'); | |
$request = $this->client->get( | |
'/sub/foo', | |
['Accept' => '*/*'], | |
['stream' => true], | |
); | |
$factory = new PhpStreamRequestFactory(); | |
$stream = $factory->fromRequest($request); | |
$line = ''; | |
while (!$stream->feof()) { | |
$line .= $stream->readLine(10); // hack | |
while (false !== strstr($line, $this->delimiter)) { | |
list($message, $line) = explode($this->delimiter, $line, 2); | |
$message = json_decode($message, true); | |
var_dump($message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment