1. Go to this page and download the library: Download dimns/websocket-php 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/ */
dimns / websocket-php example snippets
use WebSocketPHP\Server;
$log_folder = __DIR__ . '/logs/';
// PID-файл
$pid_file = __DIR__ . '/websocketphp.pid';
// Websocket порт
$ws_port = 8090;
// TCP порт
$tcp_port = 5020;
/**
* Функция для определения ИД пользователя (может отсутствовать)
*
* @param string $sid
*
* @return integer
*/
$func_get_user_id = function ($sid) {
return 0;
};
$websocket = new Server($log_folder, $pid_file, $ws_port, $tcp_port, $func_get_user_id);
$websocket->start();