addAllowUser() public method

public addAllowUser ( $user, $password )
Exemplo n.º 1
0
use Swoole\Protocol\RPCServer;
//设置PID文件的存储路径
Swoole\Network\Server::setPidFile(__DIR__ . '/app_server.pid');
/**
 * 显示Usage界面
 * php app_server.php start|stop|reload
 */
Swoole\Network\Server::start(function () {
    $AppSvr = new RPCServer();
    $AppSvr->setLogger(new \Swoole\Log\EchoLog(true));
    //Logger
    /**
     * 注册一个自定义的命名空间到SOA服务器
     * 默认使用 apps/classes
     */
    $AppSvr->addNameSpace('BL', __DIR__ . '/class');
    /**
     * IP白名单设置
     */
    $AppSvr->addAllowIP('127.0.0.1');
    $AppSvr->addAllowIP('127.0.0.2');
    /**
     * 设置用户名密码
     */
    $AppSvr->addAllowUser('chelun', 'chelun@123456');
    Swoole\Error::$echo_html = false;
    $server = Swoole\Network\Server::autoCreate('0.0.0.0', 8888);
    $server->setProtocol($AppSvr);
    //$server->daemonize(); //作为守护进程
    $server->run(array('worker_num' => 1, 'max_request' => 5000, 'dispatch_mode' => 3, 'open_length_check' => 1, 'package_max_length' => $AppSvr->packet_maxlen, 'package_length_type' => 'N', 'package_body_offset' => \Swoole\Protocol\RPCServer::HEADER_SIZE, 'package_length_offset' => 0));
});