public function run() { foreach ($this->loadPaths as $name => $path) { if (!class_exists($name, false) and !interface_exists($name, false)) { require $path; } } $this->loader->register(true); Terminal::init(); $server = new \Wrench\Server('ws://' . $this->host . ':' . $this->port, array("logger" => function ($msg, $pri) { })); $server->registerApplication("app", new PDCApp($this, $this->password)); $server->addListener(\Wrench\Server::EVENT_SOCKET_CONNECT, function ($data, $other) { $header = $other->getSocket()->receive(); if ($this->isHTTP($header)) { $other->getSocket()->send("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" . $this->data); $other->close(200); } else { $other->onData($header); } }); $server->run(); }
* Content Sync Server, v0.1 * * Copyright (c) 2013 Dave Olsen, http://dmolsen.com * Licensed under the MIT license * * The server that clients attach to to learn about content updates. See * lib/Wrench/Application/contentSyncBroadcasterApplication.php for logic * */ // turn errors on or off for debugging purposes ini_set('display_errors', 0); error_reporting(E_ALL); require __DIR__ . '/lib/SplClassLoader.php'; // load wrench $classLoader = new SplClassLoader('Wrench', __DIR__ . '/lib'); $classLoader->register(); // parse the main config for the content sync port if (!($config = @parse_ini_file(__DIR__ . "/../config/config.ini"))) { print "Missing the configuration file. Please build it using the Pattern Lab builder.\n"; exit; } $port = $config ? trim($config['contentSyncPort']) : '8002'; // start the content sync server $server = new \Wrench\Server('ws://0.0.0.0:' . $port . '/', array()); // register the application $server->registerApplication('contentsync', new \Wrench\Application\contentSyncBroadcasterApplication()); print "\n"; print "Auto-reload Server Started...\n"; print "Use CTRL+C to stop this service...\n"; // run it $server->run();
#!/usr/bin/env php <?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('Wrench', __DIR__ . '/../lib'); $classLoader->register(); $server = new \Wrench\Server('ws://localhost:8000/', array('allowed_origins' => array('mysite.localhost'))); $server->registerApplication('echo', new \Wrench\Application\EchoApplication()); $server->run();
#!/usr/bin/env php <?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('Wrench', __DIR__ . '/../lib'); $classLoader->register(); $server = new \Wrench\Server('ws://localhost:8000/', array('allowed_origins' => array('localhost'))); $server->registerApplication('chat', new \Wrench\Application\ChatApplication()); $server->run();
/*! * Page Follow Server, v0.2 * * Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com * Licensed under the MIT license * * The server that clients attach to to learn about page updates. See * lib/Wrench/Application/navSyncBroadcasterApplication.php for logic * */ // auto-load classes require __DIR__ . "/lib/SplClassLoader.php"; // load wrench $loader = new SplClassLoader('Wrench', __DIR__ . '/lib'); $loader->register(); // parse the main config for the content sync port if (!($config = @parse_ini_file(__DIR__ . "/../config/config.ini"))) { print "Missing the configuration file. Please build it using the Pattern Lab builder.\n"; exit; } // give it a default port $port = $config ? trim($config['pageFollowPort']) : '8000'; // start the content sync server $server = new \Wrench\Server('ws://0.0.0.0:' . $port . '/', array()); // register the application & run it $server->registerApplication('pagefollow', new \Wrench\Application\PageFollowApplication()); print "\n"; print "Page Follow Server Started...\n"; print "Use CTRL+C to stop this service...\n"; $server->run();
* Licensed under the MIT license * * The server that clients attach to to learn about content updates. See * lib/Wrench/Application/contentSyncBroadcasterApplication.php for logic * */ // auto-load classes require __DIR__ . "/lib/SplClassLoader.php"; // load wrench $loader = new SplClassLoader('Wrench', __DIR__ . '/lib'); $loader->register(); // parse the main config for the content sync port if (!($config = @parse_ini_file(__DIR__ . "/../config/config.ini"))) { print "Missing the configuration file. Please build it using the Pattern Lab builder.\n"; exit; } // give it a default port $port = $config ? trim($config['autoReloadPort']) : '8001'; $args = getopt("s"); $newlines = isset($args["s"]) ? true : false; // start the content sync server $server = new \Wrench\Server('ws://0.0.0.0:' . $port . '/', array()); // register the application $server->registerApplication('autoreload', new \Wrench\Application\AutoReloadApplication($newlines)); if (!isset($args["s"])) { print "\n"; print "Auto-reload Server Started...\n"; print "Use CTRL+C to stop this service...\n"; } // run it $server->run();
/*! * Nav Sync Server, v0.1 * * Copyright (c) 2013 Dave Olsen, http://dmolsen.com * Licensed under the MIT license * * The server that clients attach to to learn about page updates. See * lib/Wrench/Application/navSyncBroadcasterApplication.php for logic * */ // turn errors on or off for debugging purposes ini_set('display_errors', 0); error_reporting(E_ALL); require __DIR__ . '/lib/SplClassLoader.php'; // load wrench $classLoader = new SplClassLoader('Wrench', __DIR__ . '/lib'); $classLoader->register(); // parse the main config for the content sync port if (!($config = @parse_ini_file(__DIR__ . "/../config/config.ini"))) { print "Missing the configuration file. Please build it using the Pattern Lab builder.\n"; exit; } $port = $config ? trim($config['navSyncPort']) : '8000'; // start the content sync server $server = new \Wrench\Server('ws://0.0.0.0:' . $port . '/', array()); // register the application & run it $server->registerApplication('navsync', new \Wrench\Application\navSyncBroadcasterApplication()); print "\n"; print "Page Follow Server Started...\n"; print "Use CTRL+C to stop this service...\n"; $server->run();
* 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('Wrench', __DIR__ . '/../lib'); $classLoader->register(); // Generate PEM file $pemFile = dirname(__FILE__) . '/generated.pem'; $pemPassphrase = null; $countryName = "DE"; $stateOrProvinceName = "none"; $localityName = "none"; $organizationName = "none"; $organizationalUnitName = "none"; $commonName = "foo.lh"; $emailAddress = "*****@*****.**"; \Wrench\Socket::generatePEMFile($pemFile, $pemPassphrase, $countryName, $stateOrProvinceName, $localityName, $organizationName, $organizationalUnitName, $commonName, $emailAddress); // User can use tls in place of ssl $server = new \Wrench\Server('127.0.0.1', 8000, 'ssl', $pemFile, $pemPassphrase); // 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', \Wrench\Application\StatusApplication::getInstance()); $server->registerApplication('demo', \Wrench\Application\DemoApplication::getInstance()); $server->run();
#!/usr/bin/env php <?php ini_set('display_errors', 1); error_reporting(E_ALL); require_once __DIR__ . '/../include/lib/SplClassLoader.php'; require_once __DIR__ . '/../include/lib/log4php/Logger.php'; require_once __DIR__ . '/../settings/config.php'; Logger::configure($sr_channel_logger_config); $logger = Logger::getLogger("channel"); $classLoader = new SplClassLoader('Wrench', __DIR__ . '/../channel'); $classLoader->register(); $server = new \Wrench\Server($sr_channel_server_uri_internal, array('check_origin' => false, 'logger' => $logger, 'connection_manager_options' => array('logger' => $logger))); $config = array(); $config['rest_server'] = $sr_channel_event_rest; $config['logger'] = $logger; $logger->info($sr_channel_event_rest); $logger->info('Start channel server - ' . $sr_channel_server_uri); $server->registerApplication($sr_channel_server_key, new \Wrench\Application\SunriseChannelServer($config)); $server->run();
#!/usr/bin/env php <?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__ . '/../include/lib/SplClassLoader.php'; $classLoader = new SplClassLoader('Wrench', __DIR__ . '/../message'); $classLoader->register(); $server_ip = ''; $server_port = ''; $server = new \Wrench\Server('ws://' . $server_ip . ':' . $server_port . '/', array('check_origin' => false)); $server->registerApplication('broadcast', new \Wrench\Application\SunriseMessageBroadcastDemoServer()); $server->run();