<?php

namespace App;

use Workerman\Worker;
use Workerman\Connection\TcpConnection;

class MyWebSocketHandler
{
    public function onConnect(TcpConnection $connection): void
    {
        echo "New connection\n";
    }

    public function onMessage(TcpConnection $connection, string $data): void
    {
        $connection->send('Hello ' . $data);
    }

    public function onClose(TcpConnection $connection): void
    {
        echo "Connection closed\n";
    }
}