src/Pool.php
protected function bindClientEvents(PoolClientInterface $client)
    {
        $clientId = $client->getClientId();
        $this->_clientsStates[$clientId] = PoolClientInterface::CLIENT_POOL_STATE_READY;
        $this->_clientsQueueCounters[$clientId] = 0;

        //Remove client from pool on close
        $client->once(PoolClientInterface::CLIENT_POOL_EVENT_CLOSE, function() use ($client, $clientId) {
            unset($this->_clients[$clientId]);
            unset($this->_clientsStates[$clientId]);
            unset($this->_clientsQueueCounters[$clientId]);
            $client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE);
            $client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE);
        });
        //Change client state
        $client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, function($state) use ($client, $clientId) {
            $this->_clientsStates[$clientId] = $state;
        });
        //Change client queue count
        $client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, function($queueCount) use ($client, $clientId) {
            $this->_clientsQueueCounters[$clientId] = $queueCount;
        });
    }
protected function bindClientEvents(PoolClientInterface $client)
    {
        $clientId = $client->getClientId();
        $this->_clientsStates[$clientId] = PoolClientInterface::CLIENT_POOL_STATE_READY;
        $this->_clientsQueueCounters[$clientId] = 0;

        //Remove client from pool on close
        $client->once(PoolClientInterface::CLIENT_POOL_EVENT_CLOSE, function() use ($client, $clientId) {
            unset($this->_clients[$clientId]);
            unset($this->_clientsStates[$clientId]);
            unset($this->_clientsQueueCounters[$clientId]);
            $client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE);
            $client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE);
        });
        //Change client state
        $client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, function($state) use ($client, $clientId) {
            $this->_clientsStates[$clientId] = $state;
        });
        //Change client queue count
        $client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, function($queueCount) use ($client, $clientId) {
            $this->_clientsQueueCounters[$clientId] = $queueCount;
        });
    }
protected function bindClientEvents ( PoolClientInterface $ client ) { $ clientId = $ client -> getClientId ( ) ; $ this -> _clientsStates [ $ clientId ] = PoolClientInterface :: CLIENT_POOL_STATE_READY ; $ this -> _clientsQueueCounters [ $ clientId ] = 0 ; //Remove client from pool on close $ client -> once ( PoolClientInterface :: CLIENT_POOL_EVENT_CLOSE , function ( ) use ( $ client , $ clientId ) { unset ( $ this -> _clients [ $ clientId ] ) ; unset ( $ this -> _clientsStates [ $ clientId ] ) ; unset ( $ this -> _clientsQueueCounters [ $ clientId ] ) ; $ client -> removeAllListeners ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_STATE ) ; $ client -> removeAllListeners ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_QUEUE ) ; } ) ; //Change client state $ client -> on ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_STATE , function ( $ state ) use ( $ client , $ clientId ) { $ this -> _clientsStates [ $ clientId ] = $ state ; } ) ; //Change client queue count $ client -> on ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_QUEUE , function ( $ queueCount ) use ( $ client , $ clientId ) { $ this -> _clientsQueueCounters [ $ clientId ] = $ queueCount ; } ) ; }
Bind event handlers to client instance
@param PoolClientInterface $client
Bind event handlers to client instance