<?php

use ZPHP\ZPHP;
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
$rootPath = dirname(__DIR__);
require dirname($rootPath) . '/ZPHP/ZPHP.php';
ZPHP::setRootPath($rootPath);
//:~
$cmds = array('reload', 'shutdown', 'test');
$server = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
$cmd = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : '';
if (empty($server)) {
    exit("wrong server.\n");
}
if (!in_array($cmd, $cmds)) {
    exit("cmd must in [ " . implode("|", $cmds) . "]\n");
}
require_once "../config/{$server}/config.php";
$servInfo = array();
$servInfo['host'] = $config['socket']['host'];
$servInfo['port'] = $config['socket']['port'];
if (empty($servInfo['host']) || empty($servInfo['port'])) {
    exit("wrong server host or port.\n");
}
//:~
//发送给server的数据
$reqData = array('a' => "server\\{$cmd}");
//$reqData = array(
//    'a' => "user\\login"