Exemplo n.º 1
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();
Exemplo n.º 2
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();