예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $socket = new Socket($this->httpHost, $this->port, $this->address);
     require_once app_path() . '/Socket/routes.php';
     $this->info('Laravel web socket server started on ' . $this->httpHost . ':' . $this->port . '/' . 'address:' . $this->address);
     $socket->run();
 }
예제 #2
0
파일: Server.php 프로젝트: TheOrchid/Socket
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $socket = new Socket($this->httpHost, $this->port, $this->address);
     require base_path('routes/socket.php');
     $this->info('Laravel web socket server started on ' . $this->httpHost . ':' . $this->port . '/' . 'address:' . $this->address);
     $socket->run();
 }
예제 #3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //Init rena
     /** @var RenaApp $app */
     $app = RenaApp::getInstance();
     // Init react event loop
     $loop = Factory::create();
     // Init the ZMQ push points (?)
     $killsWebsocket = new killsWebsocket();
     $stompOut = new sendToStomp();
     // Setup ZMQ for killmails being sent around
     $context = new Context($loop);
     $pull = $context->getSocket(ZMQ::SOCKET_PULL);
     $pull->bind("tcp://" . $app->baseConfig->getConfig("host", "zmq", "127.0.0.1") . ":" . $app->baseConfig->getConfig("port", "zmq", 5555));
     $pull->on("message", array($killsWebsocket, "onMessage"));
     $pull->on("message", array($stompOut, "onMessage"));
     // Setup ratchets websocket endpoint
     $ratchet = new App($app->baseConfig->getConfig("host", "websocket", "localhost"), $app->baseConfig->getConfig("port", "websocket", 8800), $app->baseConfig->getConfig("ip", "websocket", "0.0.0.0"), $loop);
     // Add routes here, / is entry and is just spamming kills, everything else is seperate
     $ratchet->route("/", $killsWebsocket, array("*"));
     // Default route is killmails
     $ratchet->route("/kills", $killsWebsocket, array("*"));
     // Seems someone uses this too for killmails
     $ratchet->route("/echo", new echoWebsocket(), array("*"));
     // Echo route, all it'll do is echo out whatever is sent to it
     $ratchet->run();
 }
예제 #4
0
파일: Server.php 프로젝트: guanxu1/Socket
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $socket = new Socket($this->url, $this->port);
     require_once app_path() . '/Socket/routes.php';
     $this->info('Laravel web socket server started on ' . $this->url . ':' . $this->port . '/');
     $socket->run();
 }
예제 #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Starting chat server.');
     $app = new Ratchet\App("localhost", 8080, '0.0.0.0');
     $app->route('/chat', new Chat(), array('*'));
     $app->run();
     $output->writeln('Chat server stopped');
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->ratchetApp = new App($this->getHttpHost(), $this->getPort(), $this->getIpAddress(), $this->loop);
     foreach ($this->apps as $app) {
         // TODO introduce session config for this: $sessionApp = new SessionProvider($app['app'], $this->sessionHandler);
         $this->ratchetApp->route($app['route'], $app['app'], $app['allowedOrigins'], $app['httpHost']);
     }
     $this->ratchetApp->run();
 }
예제 #7
0
 private function runWebsocketListener()
 {
     try {
         $this->wsConnection->route('/' . $this->config->get('daemons.wsserver.path'), $this, array('*'));
         echo ' [*] Websockets broker daemon waiting for messages. To exit press CTRL+C', "\n";
         $this->wsConnection->run();
     } catch (\Exception $e) {
         $this->logger->error(__METHOD__ . ' | ' . $e->getMessage());
     }
 }
예제 #8
0
파일: AboutCommand.php 프로젝트: emayk/ics
 protected function about()
 {
     $this->info("=================================");
     $this->info("Integrated Central System");
     $this->info("=================================");
     $this->info('');
     $this->info("[" . date('d M Y h:i:s') . "] Create By Emay");
     $this->info("=================================");
     $chat = new Chat();
     $echoserver = new EchoServer();
     $app = new App('localhost', 8080);
     $app->route('/chat', $chat);
     $app->route('/echo', $echoserver, array('*'));
     $app->run();
     $this->info("=================================");
 }
 public function register(Application $app)
 {
     $app['ws.publisher.options'] = $app->share(function (Application $app) {
         return array_replace(['protocol' => 'tcp', 'host' => '127.0.0.1', 'port' => 13598], $app['conf']->get(['main', 'websocket-server', 'subscriber'], []));
     });
     $app['ws.task-manager.broadcaster'] = $app->share(function (Application $app) {
         return TaskManagerBroadcasterSubscriber::create($app['ws.publisher.options']);
     });
     $app['ws.event-loop'] = $app->share(function () {
         return EventLoopFactory::create();
     });
     $app['ws.server.subscriber'] = $app->share(function (Application $app) {
         return new TaskManagerSubscriberPlugin($app['ws.publisher.options'], $app['ws.event-loop'], $app['ws.server.logger']);
     });
     $app['ws.server.application'] = $app->share(function (Application $app) {
         return new SessionProvider(new WampServer($app['ws.server.phraseanet-server']), $app['session.storage.handler']);
     });
     $app['ws.server.phraseanet-server'] = $app->share(function (Application $app) {
         return new PhraseanetWampServer($app['ws.server.topics-manager'], $app['ws.server.logger']);
     });
     $app['ws.server.logger'] = $app->share(function (Application $app) {
         return $app['task-manager.logger'];
     });
     $app['ws.server.topics-manager.directives.conf'] = $app->share(function (Application $app) {
         return [new Directive(TopicsManager::TOPIC_TASK_MANAGER, true, ['task-manager'])];
     });
     $app['ws.server.topics-manager.directives'] = $app->share(function (Application $app) {
         return new DirectivesManager($app['ws.server.topics-manager.directives.conf']);
     });
     $app['ws.server.consumer-manager'] = $app->share(function (Application $app) {
         return new ConsumerManager();
     });
     $app['ws.server.topics-manager'] = $app->share(function (Application $app) {
         $manager = new TopicsManager($app['ws.server.topics-manager.directives'], $app['ws.server.consumer-manager']);
         $manager->attach($app['ws.server.subscriber']);
         return $manager;
     });
     $app['ws.server.options'] = $app->share(function (Application $app) {
         return array_replace(['host' => 'localhost', 'port' => 9090, 'ip' => '127.0.0.1'], $app['conf']->get(['main', 'websocket-server'], []));
     });
     $app['ws.server'] = $app->share(function (Application $app) {
         $options = $app['ws.server.options'];
         $server = new App($options['host'], $options['port'], $options['ip'], $app['ws.event-loop']);
         $server->route('/websockets', $app['ws.server.application']);
         return $server;
     });
 }
예제 #10
0
 /**
  * Run the server application through the WebSocket protocol
  *
  * @throws \Sonar\Exceptions\AppServiceException
  * @throws \Sonar\Exceptions\SocketServiceException
  * @return null
  */
 public function run()
 {
     if (!$this->server) {
         try {
             // initialize socket server
             $this->server = new AppServer($this->config->socket->host, $this->config->socket->port);
             // create application with dependencies
             $app = new Sonar(new StorageService($this->config->storage), new QueueService($this->config->beanstalk), new GeoService(), new CacheService());
             $this->server->route('/sonar', $app, ['*']);
         } catch (QueueServiceException $e) {
             throw new AppServiceException($e->getMessage());
         } catch (ConnectionException $e) {
             throw new SocketServiceException($e->getMessage());
         } catch (StorageServiceException $e) {
             throw new AppServiceException($e->getMessage());
         } catch (CacheServiceException $e) {
             throw new AppServiceException($e->getMessage());
         }
     }
     if (isset($this->config->storage) === false) {
         throw new AppServiceException('There is no option `storage` in your configurations');
     }
     $this->server->run();
 }
예제 #11
0
<?php

use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
use Ratchet\App;
use App\Mains;
date_default_timezone_set('Asia/Jakarta');
require dirname(__DIR__) . '/vendor/autoload.php';
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
$mains = new SessionProvider(new Mains(), new Handler\MemcacheSessionHandler($memcache));
$app = new App('pos.localhost', 8080);
$app->route('POS/Mains', $mains);
$app->run();
예제 #12
0
<?php

// Dear FIG: Thank you for PSR-0!
use Ratchet\App;
use Ratchet\Wamp\ServerProtocol;
use Ratchet\Website\Chat\Bot;
use Ratchet\Website\Chat\ChatRoom;
use Ratchet\Website\MessageLogger;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// Composer: The greatest thing since sliced bread
require dirname(__DIR__) . '/vendor/autoload.php';
$host = 'socketo.me';
if (file_exists(__DIR__ . '/config.php')) {
    require __DIR__ . '/config.php';
}
// Setup logging
$stdout = new StreamHandler('php://stdout');
$logout = new Logger('SockOut');
$login = new Logger('Sock-In');
$login->pushHandler($stdout);
$logout->pushHandler($stdout);
$app = new App($host);
$app->route('/chat', new MessageLogger(new ServerProtocol(new Bot(new ChatRoom())), $login, $logout));
// GO GO GO!
$app->run();
예제 #13
0
//Sessions
$sessionProvider = new SessionProvider();
$sessionHandler = $sessionProvider->handler();
//Servers
$apiServer = new ApiWebSocketServer();
$decoratedApiServer = new RatchetSessionProvider(new WampServer($apiServer), $sessionHandler);
$peerServer = new PeerServer($hostnames[0], $port);
$decoratedPeerServer = new RatchetSessionProvider($peerServer, $sessionHandler);
$peerHttpServer = new PeerHttpServer($peerServer);
//HTTP servers don't support SessionProvider
//Provide the peer server to the associated controller
PeerController::setPeerServer($peerServer);
PeerController::setApiServer($apiServer);
// Bind to 0.0.0.0 to accept remote connections
// See http://socketo.me/docs/troubleshooting
$app = new App($hostnames[0], $port, '0.0.0.0');
foreach ($hostnames as $host) {
    //Webos' API. Accessible from the same origin only
    $app->route('/api', $decoratedApiServer, array(), $host);
    //PeerJS server. Accessible from all origins
    $app->route('/peerjs', $decoratedPeerServer, array('*'), $host);
    $app->route('/peerjs/id', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/peers', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/id', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/offer', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/candidate', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/answer', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/leave', $peerHttpServer, array('*'), $host);
}
$app->run();
//Start the server
예제 #14
0
$sessionProvider = new SessionProvider();
$sessionHandler = $sessionProvider->handler();
//Servers
$httpServer = new WebosHttpServer($sessionHandler);
$apiServer = new ApiWebSocketServer();
$decoratedApiServer = new RatchetSessionProvider(new WampServer($apiServer), $sessionHandler);
$peerServer = new PeerServer($hostnames[0], $port);
$decoratedPeerServer = new RatchetSessionProvider($peerServer, $sessionHandler);
$peerHttpServer = new PeerHttpServer($peerServer);
//HTTP servers don't support SessionProvider
//Provide the peer server to the associated controller
PeerController::setPeerServer($peerServer);
PeerController::setApiServer($apiServer);
// Bind to 0.0.0.0 to accept remote connections
// See http://socketo.me/docs/troubleshooting
$app = new App($hostnames[0], $port, '0.0.0.0', null);
foreach ($hostnames as $host) {
    //Webos' API
    $app->route('/api/ws', $decoratedApiServer, array('*'), $host);
    //PeerJS server. Accessible from all origins
    $app->route('/peerjs', $decoratedPeerServer, array('*'), $host);
    $app->route('/peerjs/id', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/peers', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/id', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/offer', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/candidate', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/answer', $peerHttpServer, array('*'), $host);
    $app->route('/peerjs/{id}/{token}/leave', $peerHttpServer, array('*'), $host);
    // Built-in HTTP server
    $app->route('/', $httpServer, array('*'), $host);
    $app->route('/api', $httpServer, array('*'), $host);
<?php

// Your shell script
use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
use Ratchet\App;
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
$session = new SessionProvider(new MyApp(), new Handler\MemcacheSessionHandler($memcache));
$server = new App('localhost');
$server->route('/intercambio_de_perfiles/index/dashboard', $session);
$server->run();
예제 #16
0
if (!$enabled) {
    //WebSocket server not enabled
    exit('Cannot start WebSocket server: server is not enabled in ' . $serverConfigFilePath);
}
$hostname = isset($serverConfig['hostname']) ? $serverConfig['hostname'] : 'localhost';
$port = isset($serverConfig['port']) ? $serverConfig['port'] : 9000;
echo 'Starting WebSocket server at ' . $hostname . ':' . $port . '...' . "\n";
//Sessions
$sessionProvider = new SessionProvider();
$sessionHandler = $sessionProvider->handler();
//Servers
$apiServer = new ApiWebSocketServer();
$peerServer = new PeerServer($hostname, $port);
$peerHttpServer = new PeerHttpServer($peerServer);
//HTTP servers doesn't support SessionProvider
//Provide the peer server to the associated controller
PeerController::setPeerServer($peerServer);
$app = new App($hostname, $port, '0.0.0.0');
// 0.0.0.0 to accept remote connections
//Webos' API. Accessible from the same origin only
$app->route('/api', new RatchetSessionProvider($apiServer, $sessionHandler));
//PeerJS server. Accessible from all origins
$app->route('/peerjs', new RatchetSessionProvider($peerServer, $sessionHandler), array('*'));
$app->route('/peerjs/id', $peerHttpServer, array('*'));
$app->route('/peerjs/{id}/{token}/id', $peerHttpServer, array('*'));
$app->route('/peerjs/{id}/{token}/offer', $peerHttpServer, array('*'));
$app->route('/peerjs/{id}/{token}/candidate', $peerHttpServer, array('*'));
$app->route('/peerjs/{id}/{token}/answer', $peerHttpServer, array('*'));
$app->route('/peerjs/{id}/{token}/leave', $peerHttpServer, array('*'));
$app->run();
//Start the server
 /**
  * @param RatchetApp $app
  */
 private function addEchoServer(RatchetApp $app)
 {
     $server = new EchoServer();
     $app->route('/echo3', $server, ['*']);
 }