Beispiel #1
0
        }
    }
    public function onClose(ConnectionInterface $con)
    {
        if ($this->clients[$con->resourceId]) {
            $this->clients[$con->resourceId]->endGame(false);
        }
    }
    public function onError(ConnectionInterface $con, \Exception $ex)
    {
        // TODO: Log error
        try {
            try {
                if ($this->clients[$con->resourceId]) {
                    $this->clients[$con->resourceId]->endGame();
                }
            } catch (Exception $ex) {
                /* Logic might not exist anymore */
            }
            $con->close();
        } catch (Exception $ex) {
            /* Connection may already be closed */
        }
    }
}
$webSocketServer = new WsServer(new WebSocket());
$webSocketServer->disableVersion(0);
$webSocketServer->setEncodingChecks(0);
$server = IoServer::factory(new HttpServer($webSocketServer), WebSocket::$port);
echo "Server starting on port: " . WebSocket::$port . "\n";
$server->run();
Beispiel #2
0
<?php

require 'vendor/autoload.php';
// Your shell script
use ABM\Wasabi\Prestashop;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
$wasabi = new WsServer(new Prestashop());
$wasabi->disableVersion(0);
// old, bad, protocol version
$wasabi->setEncodingChecks(false);
// Make sure you're running this as root
$server = IoServer::factory(new HttpServer($wasabi), 8787, '0.0.0.0');
$server->run();