Fixed errors in examples

This commit is contained in:
Chris 2024-02-21 21:40:29 +01:00
parent 98324121f1
commit ea9865c177
2 changed files with 3 additions and 3 deletions

View File

@ -30,9 +30,9 @@ $websocket = new NoccyLabs\React\WebSocket\WebSocketMiddleware();
// Connect event handler, receives a WebSocketInterface.
// Ratchet handles security for you, this library does not. You should
// check everything important in the connect handdler and reject anything
// check everything important in the connect handler and reject anything
// that does not smell right. Here we just echo everything.
$websocket->on('connect', function (NoccyLabs\React\WebSocket\WebSocketInterface $connection) {
$websocket->on('connection', function (NoccyLabs\React\WebSocket\WebSocketInterface $connection) {
$websocket->on('text', function ($text) use ($websocket) {
$websocket->write($text);
});

View File

@ -11,7 +11,7 @@ use React\Promise\Promise;
use React\Socket\SocketServer;
$websockets = new WebSocketMiddleware();
$websockets->on('connect', function (WebSocketInterface $websocket) {
$websockets->on('connection', function (WebSocketInterface $websocket) {
$websocket->on('text', function ($text) use ($websocket) {
if (str_starts_with($text, '#')) {
$websocket->setGroup(substr($text,1));