public function connect($address)
    {
        $factory = new Factory($this->eventLoop);

        return $factory->createClient($address)
            ->then(function (Client $client) {
                $this->amiClient = $client;
                $this->actionSender = new ActionSender($client);
                $this->actionSender->events(true);
                $client->on('close', function () {
                    $this->logger->debug('AMI connection closed');
                });
                $client->on('event', function (Event $event) {
                    $this->wsClient->emit($event->getName(), (array)$event);
                });
            }, function (\Exception $e) {
                $this->logger->err('Connection error: '.$e->getMessage());
            });
    }
public function connect($address)
    {
        $factory = new Factory($this->eventLoop);

        return $factory->createClient($address)
            ->then(function (Client $client) {
                $this->amiClient = $client;
                $this->actionSender = new ActionSender($client);
                $this->actionSender->events(true);
                $client->on('close', function () {
                    $this->logger->debug('AMI connection closed');
                });
                $client->on('event', function (Event $event) {
                    $this->wsClient->emit($event->getName(), (array)$event);
                });
            }, function (\Exception $e) {
                $this->logger->err('Connection error: '.$e->getMessage());
            });
    }
public function connect ( $ address ) { $ factory = new Factory ( $ this -> eventLoop ) ; return $ factory -> createClient ( $ address ) -> then ( function ( Client $ client ) { $ this -> amiClient = $ client ; $ this -> actionSender = new ActionSender ( $ client ) ; $ this -> actionSender -> events ( true ) ; $ client -> on ( 'close' , function ( ) { $ this -> logger -> debug ( 'AMI connection closed' ) ; } ) ; $ client -> on ( 'event' , function ( Event $ event ) { $ this -> wsClient -> emit ( $ event -> getName ( ) , ( array ) $ event ) ; } ) ; } , function ( \ Exception $ e ) { $ this -> logger -> err ( 'Connection error: ' . $ e -> getMessage ( ) ) ; } ) ; }
Connect to AMI and start emitting events.

@param string $address Example uaername:password@localhost:5038
@return \React\Promise\Promise
Connect to AMI and start emitting events .