24 lines
587 B
PHP
24 lines
587 B
PHP
<?php
|
|
|
|
require_once __DIR__."/../vendor/autoload.php";
|
|
|
|
use NoccyLabs\React\Protocol\Json\JsonProtocol;
|
|
use NoccyLabs\React\Protocol\ProtocolStream;
|
|
use React\Stream\CompositeStream;
|
|
use React\Stream\ThroughStream;
|
|
use React\Stream\WritableResourceStream;
|
|
|
|
$rs = new ThroughStream();
|
|
$ws = new WritableResourceStream(STDOUT);
|
|
$stream = new CompositeStream($rs,$ws);
|
|
|
|
$proto = new JsonProtocol(
|
|
frameSeparator: "\n",
|
|
prependSizeBytes: 0,
|
|
);
|
|
$stream = new ProtocolStream($stream, $proto);
|
|
|
|
$stream->send([ 'hello' => 'world' ]);
|
|
$stream->send([ 'foo' => 'bar', 'answer' => 42 ]);
|
|
|