Example #1
0
void connection_mgr::on_connected() {
    connected_sig();

    auto self = shared_from_this();

    m_connection->send_command("list_remotes", "" , [self] ( const bs::error_code &ec
                               , const std::string& status
    , std::string& data ) {

        bs::error_code _ec = ec;

        if (!_ec && status != "k")
            _ec = make_iks_error_code(data);

        if (!_ec) {
            std::vector<remote_entry> remotes;
            if (self->parse_remotes(data, remotes))
                for (auto& e : remotes)
                    self->connect_location(e.first, e.second);
            else
                _ec = make_error_code(iks_client_error::invalid_server_response);
        }

        if (_ec)
            self->on_error(_ec);

        return IksCmdStatus::cmd_done;
    });
}
Example #2
0
void IksConnection::handle_connected()
{
	sz_log(10, "IksConnection(%p):handle_connected", this);

	bs::error_code _ec;
	connect_timeout_timer.cancel(_ec);

	state = CONNECTED;
	connected_sig();

	schedule_keepalive();
}
void location_connection::connect_to_location() 
{
	auto self = shared_from_this();

	m_connection->send_command("connect" , m_location,
			[self] ( const bs::error_code& ec, const std::string& status, std::string& data ) {

		sz_log( 5 , "location_connection(%p)::connect_to_location error: %s"
		      , self.get() , ec.message().c_str() );

		if ( ec ) {
			self->connection_error_sig( ec );
			return IksCmdStatus::cmd_done;
		}

		if ( status != "k" ) {
			sz_log( 5 , "location_connection(%p)::connect_to_location not ok from server"
			        " error: %s , data: %s" , self.get(), status.c_str() , data.c_str() );

			self->connection_error_sig( make_iks_error_code( data ) );
			return IksCmdStatus::cmd_done;
		}

		sz_log( 10 , "location_connection(%p)::connected " , self.get() );

		self->m_connected = true;

		self->add_defined_params();

		self->send_cached();

		self->connected_sig();

		return IksCmdStatus::cmd_done;

	});
}
void location_connection::connect_to_location() 
{
	auto self = shared_from_this();

	m_connection->send_command("connect" , m_location,
			[self] ( const bs::error_code& ec, const std::string& status, std::string& data ) {
		if ( ec )
			return IksCmdStatus::cmd_done;

		if ( status != "k" ) {
			self->connection_error_sig( make_iks_error_code( data ) );
			return IksCmdStatus::cmd_done;
		}

		///XXX: 1. send defined params
		///XXX: 2. send cached

		self->connected_sig();
		self->m_connected = true;

		return IksCmdStatus::cmd_done;

	});
}
Example #5
0
void IksConnection::handle_connected()
{
	connected_sig();
}