public function __construct()
{
$this->table = new swoole_table(1024);
$this->table->column('serverfd', swoole_table::TYPE_INT, 8);
$this->table->create();
define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
define('MYPATH', dirname(APPLICATION_PATH));
$this->application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
$this->application->bootstrap();
$config_obj = Yaf_Registry::get("config");
$distributed_config = $config_obj->distributed->toArray();
$server = new swoole_server($distributed_config['ServerIp'], $distributed_config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
if (isset($distributed_config['logfile'])) {
$server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true, 'log_file' => $distributed_config['logfile']));
} else {
$server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true));
}
require_once __DIR__ . "/DistributedClient.php";
$server->on('Start', array(&$this, 'onStart'));
$server->on('WorkerStart', array(&$this, 'onWorkerStart'));
$server->on('Connect', array(&$this, 'onConnect'));
$server->on('Receive', array(&$this, 'onReceive'));
$server->on('Task', array(&$this, 'onTask'));
$server->on('Finish', array(&$this, 'onFinish'));
$server->on('Close', array(&$this, 'onClose'));
$server->on('ManagerStop', array(&$this, 'onManagerStop'));
$server->on('WorkerError', array(&$this, 'onWorkerError'));
$server->start();
}