def establish_connection(settings)
@settings = Settings.configure(settings)
socket = Socket.connect(self, @settings[:host], @settings[:port])
socket.attach(Cool.io::Loop.default)
self.socket = socket
@on_tcp_connection_failure = @settings[:on_tcp_connection_failure] || Proc.new { |settings|
raise self.class.tcp_connection_failure_exception_class.new(settings)
}
@on_possible_authentication_failure = @settings[:on_possible_authentication_failure] || Proc.new { |settings|
raise self.class.authentication_failure_exception_class.new(settings)
}
@locale = @settings.fetch(:locale, "en_GB")
@client_properties = Settings.client_properties.merge(@settings.fetch(:client_properties, Hash.new))
@auto_recovery = (!!@settings[:auto_recovery])
socket
end