Closed programarivm closed 5 months ago
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Connection\TcpConnection; use Workerman\Worker;
$ws = new Worker('websocket://0.0.0.0:8181'); $ws->onConnect = function($connection) { $connection->onWebSocketConnect = function($connection , $httpBuffer) { // This is where you can determine if the connection is from a legitimate source and close it if it is not. // $_SERVER['HTTP_ORIGIN'] identifies the site from which the page initiated the websocket connection. if($_SERVER['HTTP_ORIGIN'] != 'https://www.workerman.net') { $connection->close(); } // onWebSocketConnect where $_GET $_SERVER is available. // var_dump($_GET, $_SERVER); }; }; Worker::runAll();
Hello there,
I've been able to successfully implement the cli/workerman/staging.php script which is now running as shown below.
Now I'd want to write a production script called cli/workerman/prod.php to enable some restrictions similarly as with cli/ratchet/prod.php.
Here are two questions.
Thank you for the help, and keep it up.