DistributedServer::onStart PHP Method

onStart() public method

public onStart ( $serv )
    public function onStart($serv)
    {
        $localinfo = swoole_get_local_ip();
        $this->localip = current($localinfo);
        $serverlist = DistributedClient::getInstance()->getserlist();
        $result_fd = json_decode($serverlist, true);
        if (!empty($result_fd)) {
            foreach ($result_fd as $id => $fd) {
                if ($fd != $this->localip) {
                    $client = DistributedClient::getInstance()->addServerClient($fd);
                    $this->table->set(ip2long($fd), array('serverfd' => ip2long($fd)));
                    $this->b_server_pool[ip2long($fd)] = array('fd' => $fd, 'client' => $client);
                }
            }
        }
        DistributedClient::getInstance()->appendserlist($this->localip, ip2long($this->localip));
    }