Ejemplo n.º 1
0
 public function __construct($wsport)
 {
     $this->say('Creating server');
     // Logger (required for handlers)
     $this->logger = new \Zend\Log\Logger();
     // Log PHP errors
     Zend\Log\Logger::registerErrorHandler($this->logger);
     // Writes to stdout
     $writer = new \Zend\Log\Writer\Stream("php://output");
     $this->logger->addWriter($writer);
     // Also log to a file
     //$writer2 = new Zend\Log\Writer\Stream('/path/to/logfile');
     //$this->logger->addWriter($writer2);
     // Filter log messages not showing debug
     //$filter = new Zend\Log\Filter\Priority(\Zend\Log\Logger::WARN);
     $filter = new Zend\Log\Filter\Priority(\Zend\Log\Logger::CRIT);
     $writer->addFilter($filter);
     //$writer2->addFilter($filter);
     // WebSocket server
     $this->loop = \React\EventLoop\Factory::create();
     $this->server = new \Devristo\Phpws\Server\WebSocketServer("tcp://0.0.0.0:{$wsport}", $this->loop, $this->logger);
     // Handlers
     $this->index = new IndexHandler($this->logger, $this, 'index');
     $this->tournament = new TournamentIndexHandler($this->logger, $this, 'tournament');
     $this->draft = new DraftHandler($this->logger, $this, 'draft');
     $this->build = new BuildHandler($this->logger, $this, 'build');
     $this->game = new GameHandler($this->logger, $this, 'game');
     $this->admin = new AdminHandler($this->logger, $this, 'admin');
     $this->handlers = array('index', 'tournament', 'draft', 'build', 'game', 'admin');
     // Routes
     $router = new \Devristo\Phpws\Server\UriHandler\ClientRouter($this->server, $this->logger);
     $router->addRoute('#^/index#i', $this->index);
     $router->addRoute('#^/game#i', $this->game);
     $router->addRoute('#^/tournament#i', $this->tournament);
     $router->addRoute('#^/draft#i', $this->draft);
     $router->addRoute('#^/build#i', $this->build);
     $router->addRoute('#^/admin#i', $this->admin);
     // Params
     global $ts3;
     $this->ts3 = $ts3;
     $this->say('Server created');
 }
Ejemplo n.º 2
0
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
// Include paths
set_include_path(__DIR__ . PATH_SEPARATOR . realpath(__DIR__ . '/lib') . PATH_SEPARATOR . realpath(__DIR__ . '/vendor/zf2/library') . PATH_SEPARATOR . get_include_path());
// Class autoloading
require 'Lpf/Loader.php';
Lpf_Loader::loadClass('Lpf_ErrorHandler');
set_exception_handler(array('Lpf_ErrorHandler', 'exceptionHandler'));
Lpf_Loader::registerAutoload();
// Logger
$logger = new \Zend\Log\Logger();
$writer = new Zend\Log\Writer\Stream(__DIR__ . '/application.log');
$logger->addWriter($writer);
$filter = new Zend\Log\Filter\Priority(Config::LOG_LEVEL);
$writer->addFilter($filter);
Zend\Log\Logger::registerErrorHandler($logger);
/**
 * @method static void debug() debug(string $message, array $extra = array())
 * @method static void info() info(string $message, array $extra = array())
 * @method static void notice() notice(string $message, array $extra = array())
 * @method static void warn() warn(string $message, array $extra = array())
 * @method static void err() err(string $message, array $extra = array())
 * @method static void crit() crit(string $message, array $extra = array())
 * @method static void alert() alert(string $message, array $extra = array())
 * @method static void emerg() emerg(string $message, array $extra = array())
 */
class Log
{
    private static $logger;
    /**
     * @return \Zend\Log\Logger