-
Cool stuff, I'm hyped! Would it be possible to receive a link or quick explanation on how to get WebSockets working? $app->get('/stream', function (ServerRequestInterface $request) {
$stream = new ThroughStream();
$stream->write(microtime(true) . ' hi!' . PHP_EOL);
return new React\Http\Message\Response(
200,
[
'Content-Type' => 'text/event-stream'
],
$stream
);
}); I managed to get this from the examples and connect, but the stream is not receiving data when using WebSocket JS API. Where does Ratchet come in the picture? ~ Wouter |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@uuouter Thanks for bringing this up, excellent question! WebSockets can be used by including https://github.com/ratchetphp/Ratchet, in particular by using https://github.com/voryx/WebSocketMiddleware. All packages share a common dependency tree and build on top of ReactPHP, so integration should be fairly straightforward. As an alternative, you may also use Server-Sent Events (EventSource) which doesn't require any external dependencies, see also #68 for more details. I'm still working on the documentation to cover this in more detail, but I hope this helps you to get started 👍 |
Beta Was this translation helpful? Give feedback.
-
A routing as simple as kemalcr.com might be cool.
|
Beta Was this translation helpful? Give feedback.
@uuouter Thanks for bringing this up, excellent question!
WebSockets can be used by including https://github.com/ratchetphp/Ratchet, in particular by using https://github.com/voryx/WebSocketMiddleware. All packages share a common dependency tree and build on top of ReactPHP, so integration should be fairly straightforward.
As an alternative, you may also use Server-Sent Events (EventSource) which doesn't require any external dependencies, see also #68 for more details.
I'm still working on the documentation to cover this in more detail, but I hope this helps you to get started 👍