public function run($connections, $autorun = true)
{
if (!is_array($connections)) {
$connections = array($connections);
}
$this->on('connect.error', function ($message, $connection, $logger) {
$logger->error($message);
});
$this->emit('connect.before.all', array($connections));
foreach ($connections as $connection) {
$this->addConnection($connection);
}
$writes = array_map(function ($connection) {
return $connection->getOption('write');
}, $connections);
$this->emit('connect.after.all', array($connections, $writes));
if ($autorun) {
$this->getLoop()->run();
}
}