/** * The main and only function needed to be called to initialise the socket server * @param null $strHostAddress * @param null $intPort */ public function server($strHostAddress = null, $intPort = null) { \Twist::Session()->start(); \Twist::framework()->register()->cancelHandler('error'); \Twist::framework()->register()->cancelHandler('fatal'); \Twist::framework()->register()->cancelHandler('exception'); if (is_null($strHostAddress)) { $strHostAddress = \Twist::framework()->setting('WS_SERVER_HOST'); } if (is_null($intPort)) { $intPort = \Twist::framework()->setting('WS_SERVER_PORT'); } CronLock::$strLockLocation = __DIR__ . '/../lock/'; //Remove the lock on complete failure, fatal error and exception \Twist::framework()->register()->shutdownEvent('CronLock', '\\Packages\\WebSockets\\Models\\CronLock', "destroy"); //Only start if their is no lock file present if (!CronLock::active()) { //Create a lock file so that the server will function CronLock::create(); $this->listen($strHostAddress, $intPort); //Remove the lock on safe shutdown of the server CronLock::destroy(); } }
public function _index() { $arrConnectionData = array('ws_host' => array_key_exists('ws_host', $_GET) ? $_GET['ws_host'] : \Twist::framework()->setting('WS_SERVER_HOST'), 'ws_port' => array_key_exists('ws_port', $_GET) ? $_GET['ws_port'] : \Twist::framework()->setting('WS_SERVER_PORT'), 'session_key' => \Twist::Session()->data('user-session_key')); return $this->_view('manager/overview.tpl', $arrConnectionData); }