Puts a server under the management of this module.
The server will be initialized by calling the init() method.
@param STRING $id server ID
@param OBJECT $server server object.
@param BOOLEAN if successful true, else false
164667
function (id,server)
		{
			if (!_.isString(id) || !_.isObject(server))
				return false;

			if (this.hasModule('server-'+id) && server == null)
				delete this.getModule('server-'+id);
			else
				this.setModule('server-'+id,server);
		}
442380
public function onWorkerStart(Server $server, int $workerId)
    {
        // Init Worker and TaskWorker
        $setting = $server->setting;
        $isWorker = false;

        if ($workerId >= $setting['worker_num']) {
            // TaskWorker
            ApplicationContext::setContext(ApplicationContext::TASK);
            ProcessHelper::setProcessTitle($this->serverSetting['pname'] . ' task process');
        } else {
            // Worker
            $isWorker = true;
            ApplicationContext::setContext(ApplicationContext::WORKER);
            ProcessHelper::setProcessTitle($this->serverSetting['pname'] . ' worker process');
        }

        $this->beforeWorkerStart($server, $workerId, $isWorker);

        $this->fireServerEvent(SwooleEvent::ON_WORKER_START, [$server, $workerId, $isWorker]);
    }
771393
public function initialize(Server $server)
    {
        $this->server = $server;
        $server->on('method:POST', [$this, 'httpPost']);
        $server->on('propFind', [$this, 'propFind']);
        $server->on('propPatch', [$this, 'propPatch']);
        $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
        $server->on('beforeUnbind', [$this, 'beforeUnbind']);
        $server->on('schedule', [$this, 'scheduleLocalDelivery']);
        $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);

        $ns = '{'.self::NS_CALDAV.'}';

        /*
         * This information ensures that the {DAV:}resourcetype property has
         * the correct values.
         */
        $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox';
        $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox';

        /*
         * Properties we protect are made read-only by the server.
         */
        array_push($server->protectedProperties,
            $ns.'schedule-inbox-URL',
            $ns.'schedule-outbox-URL',
            $ns.'calendar-user-address-set',
            $ns.'calendar-user-type',
            $ns.'schedule-default-calendar-URL'
        );
    }
1134183
public function beforeSend(Server $server)
    {

        // Build the server code
        $this->server_code = implode('', array_map('chr', explode('.', $server->ip()))) .
                             pack("S", $server->portClient());

        // Loop over the packets and update them
        foreach ($this->packets as $packetType => $packet) {
            // Fill out the packet with the server info
            $this->packets[$packetType] = sprintf($packet, $this->server_code);
        }
    }
271974
public function initialize(Server $server)
    {
        $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] =
            '{http://calendarserver.org/ns/}subscribed';

        $server->xml->elementMap['{http://calendarserver.org/ns/}source'] =
            'Sabre\\DAV\\Xml\\Property\\Href';

        $server->on('propFind', [$this, 'propFind'], 150);
    }
691775
public function onStart(Server $server): void
    {
        $this->fire(ServerEvent::STARTED, $server);

        $this->masterPid = $masterPid = $server->master_pid;
        $rootPath        = $this->config('rootPath');
        $rootPath        = $rootPath ? " (at $rootPath)" : '';

        // save master process id to file.
        ProcessUtil::setTitle(sprintf('%s: master%s', $this->name, $rootPath));

        $this->log("The <comment>master</comment> process success started. (PID:<info>{$masterPid}</info>, pidFile: $this->pidFile)");
    }
594382
private function _addServer($server)
    {
        $server = $this->_parseMemcacheAddress($server);
        $this->_server->addServer(
            $server['host'], $server['port'], isset($server['persistent']) ? $server['persistent'] : true, isset($server['weight']) ? $server['weight'] : 1, isset($server['timeout']) ? $server['timeout'] : 15, isset($server['retry_interval']) ? $server['retry_interval'] : 15
        );
    }
1287857
public function setId($id)
    {
        if (!is_null($id)) {
            $id = (string) $id;
        }

        $this->id = $id;
        return $this;
    }
1237756
function setServer($server)
    {
        $this->server = new DataEntity(
            $this->_normalizeServer($server)
        );
        
        return $this->server;
    }
285910
private function afterCommand(string $command, bool $server)
    {
        if ($server) {
            return;
        }

        App::getLogger()->appendNoticeLog(true);
    }
562717
public final void addServer(final String server, final int port, int weight) throws IOException {
    if (weight <= 0) {
      throw new IllegalArgumentException("weight<=0");
    }
    this.checkServerPort(server, port);
    this.connect(new InetSocketAddressWrapper(this.newSocketAddress(server, port),
        this.serverOrderCount.incrementAndGet(), weight, null));
  }
763561
public synchronized void onServerReconnected(final String id, final String uri) {
        logger.debug("[onServerReconnected] id = {}, uri = {}", id, uri);

        if (id.length() == 0) {
            Server server = getServerByUri(uri);
            server.register();
            server.setAvailable(true);
        }

        refreshServers();
    }
342404
public function createOrUpdate($id, $instanceName, $content)
    {
        if ($this->exists($id, $instanceName)) {
            $this->update($id, $instanceName, $content);
        } else {
            $this->create($id, $instanceName, $content);
        }
    }
1267524
public function onClose($server, $serverSocket, $id)
    {
        if (isset($this->connections[$id])) {
            $this->fireCloseEvent(
                $this->connections[$id]['handler'],
                $this->connections[$id]['connection']
            );

            unset($this->connections[$id]);
        }
    }
311800
public function setServerId(int $nb_server_id) : CNabuDataObject
    {
        if ($nb_server_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_server_id")
            );
        }
        $this->setValue('nb_server_id', $nb_server_id);
        
        return $this;
    }
517137
protected function addServer(string $type, Server $server)
    {
        switch ($type) {
            case 'master':
                $this->servers['master'] = ['server' => $server, 'connection' => null];

                break;
            default:
                $serverHashId = spl_object_hash($server);

                if (!isset($this->servers[$type][$serverHashId])) {
                    $this->servers[$type][$serverHashId] = ['server' => $server, 'connection' => null];
                }

                break;
        }
    }
1015212
public function restart($id = false)
    {
        if ($id) {
            $this->_id = $id;
        }

        $this->_user->put('pylon/start', array('id' => $this->_id));
    }