/**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $server = new \WebSocket\Server(['timeout' => 200, 'port' => 8901]);
     echo $server->getPort(), "\n";
     while ($connection = $server->accept()) {
         echo "Connected!\n";
         while (1) {
             $message = $server->receive();
             echo "Received {$message}\n\n";
             // //{"type":"message","channel":"D0Y7J3MHT","user":"******","text":"!test","ts":"1476761016.000065","team":"T0BLLQ1M3"}
             $server->send(json_encode(['type' => 'message', 'channel' => 'D01234567', 'user' => 'U76543210', 'text' => '!test', 'ts' => '1476761016.000065', 'team' => 'T01234567']));
             sleep(5);
         }
     }
 }
示例#2
0
<?php

error_reporting(E_ALL);
require __DIR__ . '/lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$server = new \WebSocket\Server('localhost', 8000);
$server->registerApplication('echo', \WebSocket\Application\EchoApplication::getInstance());
$server->run();
示例#3
0
<?php

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The F**k You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */
ini_set('display_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
// require $hostName, $permitDomain, $wsPort, $wsSSL
$infoPath = dirname(__FILE__) . '/../../../hidden/info.php';
require $infoPath;
// TEST SSL対応の為 第3引数 false を true に変更
$server = new \WebSocket\Server($hostName, $wsPort, $wsSSL);
// server settings:
$server->setMaxClients(200);
$server->setCheckOrigin(true);
// 通信を許可するドメイン 複数指定可能
$server->setAllowedOrigin($permitDomain);
$server->setMaxConnectionsPerIp(400);
$server->setMaxRequestsPerMinute(4000);
// Hint: Status application should not be removed as it displays usefull server informations:
//個別のアプリケーションの登録 Happy2用
$server->registerApplication('happy2', \WebSocket\Application\Happy2Application::getInstance());
$server->run();
示例#4
0
<?php

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The F**k You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */
ini_set('display_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$server = new \WebSocket\Server('127.0.0.1', 8000, false);
// server settings:
$server->setMaxClients(100);
$server->setCheckOrigin(true);
$server->setAllowedOrigin('foo.lh');
$server->setMaxConnectionsPerIp(100);
$server->setMaxRequestsPerMinute(2000);
// Hint: Status application should not be removed as it displays usefull server informations:
$server->registerApplication('status', \WebSocket\Application\StatusApplication::getInstance());
$server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance());
$server->run();
示例#5
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
ini_set('display_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$server = new \WebSocket\Server('127.0.0.1', 8000, false);
$server->setMaxClients(100);
$server->setCheckOrigin(false);
$server->setMaxConnectionsPerIp(100);
$server->setMaxRequestsPerMinute(2000);
$server->registerApplication('mazerunner', \WebSocket\Application\MazeApplication::getInstance());
$server->run();
示例#6
0
ini_set('display_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('America/Sao_Paulo');
$config_host = "172.20.80.2";
$config_port = "80";
$config_clients = 5000;
$config_connections = 5000;
$config_check = FALSE;
$config_origin = "";
$config_requests = 12000;
$config_id = 1;
require 'lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$server = new \WebSocket\Server($config_host, $config_port, false);
echo "\n\nStarting at: " . $config_host . ":" . $config_port . " (" . date("H:i:s") . ")\n\n";
// server settings:
$server->socket_id = $config_id;
$server->setMaxClients($config_clients);
$server->setMaxConnectionsPerIp($config_connections);
$server->setMaxRequestsPerMinute($config_requests);
if ($config_check && $config_origin != "") {
    $server->setCheckOrigin($config_check);
    $server->setAllowedOrigin($config_origin);
} else {
    $server->setCheckOrigin(FALSE);
}
$server->registerApplication('secondscreenapp', \WebSocket\Application\SecondscreenApp::getInstance());
$server->registerApplication('chatapp', \WebSocket\Application\ChatApp::getInstance());
$server->run();
示例#7
0
                    $c->send(json_encode($container[$channel]));
                    unset($container[$channel]);
                    return;
                }
            }
        }
    }
    protected function pushToc2c($channel)
    {
        return $this->push($channel, 'isC2C', $this->resultStorage);
    }
    protected function pushToHook($channel)
    {
        return $this->push($channel, 'isHook', $this->commandStorage);
    }
}
echo <<<EOF
XSS ChEF server
by Krzysztof Kotowicz - kkotowicz at gmail dot com

Usage: php server.php [port=8080] [host=127.0.0.1]
Communication is logged to stderr, use php server.php [port] 2>log.txt

EOF;
$port = !empty($argv[1]) ? (int) $argv[1] : 8080;
$ip = !empty($argv[2]) ? $argv[2] : '127.0.0.1';
$server = new \WebSocket\Server($ip, $port, false);
echo date('Y-m-d H:i:s') . ' ChEF server is listening on ' . $ip . ':' . $port . "\n";
$server->setCheckOrigin(false);
$server->registerApplication('chef', xssChefServerApplication::getInstance());
$server->run();