예제 #1
0
 /**
  * Start transportprovider
  *
  * @param \Thruway\Peer\AbstractPeer $peer
  * @param \React\EventLoop\LoopInterface $loop
  */
 public function startTransportProvider(AbstractPeer $peer, LoopInterface $loop)
 {
     $this->peer = $peer;
     $this->loop = $loop;
     $ws = new WsServer($this);
     $ws->disableVersion(0);
     $socket = new Reactor($this->loop);
     $socket->listen($this->port, $this->address);
     $this->server = new IoServer(new HttpServer($ws), $socket, $this->loop);
 }
예제 #2
0
 public function testTcpFragmentedUpgrade()
 {
     $headers = $this->headerProvider();
     $body = base64_decode($this->_body);
     $mockConn = $this->getMock('\\Ratchet\\ConnectionInterface');
     $mockApp = $this->getMock('\\Ratchet\\MessageComponentInterface');
     $server = new WsServer($mockApp);
     $server->onOpen($mockConn);
     $server->onMessage($mockConn, $headers);
     $mockApp->expects($this->once())->method('onOpen');
     $server->onMessage($mockConn, $body . $this->_crlf . $this->_crlf);
 }
예제 #3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Starting server");
     $manager = $this->getContainer()->get("bordeux.websocket.service.connection.manager");
     $manager->setOutput($output);
     $ws = new WsServer($manager);
     $ws->disableVersion(0);
     $server = IoServer::factory(new HttpServer($ws), (int) $input->getOption('port'), $input->getOption('ip'));
     $manager->setLoop($server->loop);
     $routingManager = $this->getContainer()->get("bordeux.websocket.service.routing.manager");
     $routingManager->setConnectionManager($manager);
     $manager->setRoutes($routingManager->findRoutes());
     $server->run();
 }
예제 #4
0
#!/usr/bin/php
<?php 
/**
 * Entry point
 */
require dirname(__DIR__) . '/vendor/autoload.php';
// APP CONFIG
define('PORT', 8000);
define('IP', '127.0.0.1');
define('USER_BASKET_SIZE', 100);
define('UNIVERSE_BASKET_SIZE', 10);
define('UNIVERSE_BASKET_COUNT', 30);
define('MAX_BALL_NUMBER', 999);
// Your shell script
use Ratchet\WebSocket\WsServer;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
$basketFactory = new \Bttw\Domain\BasketFactory\RandomBasketFactory(\Bttw\Domain\Basket\HashMapBasket::class, MAX_BALL_NUMBER);
$ws = new WsServer(new \Bttw\Infrastructure\Controller($basketFactory));
$ws->disableVersion(0);
// old, bad, protocol version
// Make sure you're running this as root
echo sprintf('Started websocket server on %s:%d' . "\n", IP, PORT);
$server = IoServer::factory(new HttpServer($ws), PORT, IP);
$server->run();
예제 #5
0
<?php

namespace StatusOnline;

use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use StatusOnline\Server\Component;
const VERSION = 'v0.3-beta';
const AUTHOR = 'Vitaliy IIIFX Khomenko <*****@*****.**>';
const GITHUB = 'https://github.com/iiifx';
$loader = (require __DIR__ . '/../../vendor/autoload.php');
$loader->add('', realpath(__DIR__ . '/../'));
$wsServer = new WsServer(new Component());
$wsServer->disableVersion(0);
$ioServer = IoServer::factory(new HttpServer($wsServer), Console\Params::get('port', 8080));
$ioServer->run();
예제 #6
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();
예제 #7
0
 public function handleRouterStart(RouterStartEvent $event)
 {
     $ws = new WsServer($this);
     $ws->disableVersion(0);
     $socket = new Reactor($this->loop);
     $socket->listen($this->port, $this->address);
     Logger::info($this, "Websocket listening on " . $this->address . ":" . $this->port);
     $this->server = new IoServer(new HttpServer($ws), $socket, $this->loop);
 }
예제 #8
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();