Updated readme, example

This commit is contained in:
Chris 2024-02-24 14:18:26 +01:00
parent 899dd3b7e4
commit 7154b1baed
2 changed files with 8 additions and 7 deletions

View File

@ -4,12 +4,12 @@ This is a library that implements WebSocket support on top of ReactPHPs HttpServ
## Missing Features
The following features are missing, or work in progress:
This library is under development, and should not be used in any projects yet. The API and implementation may change in the future, and some features are still not implemented, or work in progress:
* Idle timeout and ping timeout
* Protocol errors should close with error codes
* Exceptions
* Full tested support for fragmented frames
* Timeouts -- Disconnect the client on ping/pong timeout, and optionally on inactivity/idle.
* Error Handling -- Protocol errors should close the connection etc.
* Exceptions -- Exceptions should be thrown when relevant errors are encountered, such as bad encoding or data.
* Fragmented Messages -- Sending and receiving messages fragmented over multiple frames need work.
## Installing

View File

@ -19,16 +19,17 @@ $websockets->on('connection', function (WebSocketInterface $websocket) {
// This just echoes text received, unless the websocket is part of a group.
// In this case the message is sent to all websockets in the group.
$websocket->on('text', function ($text) use ($websocket) {
// Send a message with the group name starting with '#' to join a group.
if (str_starts_with($text, '#')) {
$websocket->setGroup(substr($text,1));
$websocket->write("joined group {$text}");
} else {
// Echo back if not in group, send to group otherwise
if (!$websocket->getGroup())
$websocket->write($text);
else
foreach ($websocket->getGroup() as $member) {
foreach ($websocket->getGroup() as $member)
$member->write($text);
}
}
});
});