DistributedClient::addServerClient PHP Method

addServerClient() public method

public addServerClient ( $address )
    public function addServerClient($address)
    {
        $client = new swoole_client(SWOOLE_TCP, SWOOLE_SOCK_ASYNC);
        $client->on('Connect', array(&$this, 'onConnect'));
        $client->on('Receive', array(&$this, 'onReceive'));
        $client->on('Close', array(&$this, 'onClose'));
        $client->on('Error', array(&$this, 'onError'));
        $config_obj = Yaf_Registry::get("config");
        $distributed_config = $config_obj->distributed->toArray();
        $client->connect($address, $distributed_config['port']);
        $this->cur_address = $address;
        $this->table->set(ip2long($address), array('clientfd' => ip2long($address)));
        $this->b_client_pool[ip2long($address)] = $client;
        return $client;
    }