From 7154b1baed613a0eb21caf688cfaf3847218e2f7 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sat, 24 Feb 2024 14:18:26 +0100 Subject: [PATCH] Updated readme, example --- README.md | 10 +++++----- examples/server.php | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7e623ce..4854c10 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/server.php b/examples/server.php index 612e5fd..91dd203 100644 --- a/examples/server.php +++ b/examples/server.php @@ -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); - } } }); });