PHP code example of gonzakpo / websocket-bundle
1. Go to this page and download the library: Download gonzakpo/websocket-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gonzakpo / websocket-bundle example snippets
// src/Handler/WelcomeHandler.php
namespace App\Handler;
use Ratchet\ConnectionInterface;
use RollandRock\WebsocketBundle\Client\ClientStack;
use RollandRock\WebsocketBundle\Handler\HandlerInterface;
class WelcomeHandler implements HandlerInterface
{
public static function getName(): string
{
return 'welcome';
}
public function handle(ClientStack $clientStack, ConnectionInterface $from, array $data)
{
// Handle the "welcome" message sent by $from, containing $data.
// You also have access to the whole clients stack
}
}