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());
            });
    }