Ejemplo n.º 1
0
QSharedPointer<Ubicacion> MovimientoStock::ubicacion()
{
    if ((_idUbicacion != -1) && (_ubicacion.isNull()))
    {
        ResponsePtr response = ModelContainer::instance().model(MODELS::UBICACIONES)->get(_idUbicacion);
        if (response->list().count() > 0)
            _ubicacion = qSharedPointerDynamicCast<Ubicacion>(response->list().at(0));
    }
    return _ubicacion;
}
Ejemplo n.º 2
0
QSharedPointer<Producto> MovimientoStock::producto()
{
    if ((_idProducto != -1) && (_producto.isNull()))
    {
        ResponsePtr response = ModelContainer::instance().model(MODELS::PRODUCTOS)->get(_idProducto);
        if (response->list().count() > 0)
            _producto = qSharedPointerDynamicCast<Producto>(response->list().at(0));
    }
    return _producto;
}
Ejemplo n.º 3
0
QSharedPointer<Usuario> MovimientoStock::usuario()
{
    if ((_idUsuario != -1) && (_usuario.isNull()))
    {
        ResponsePtr response = ModelContainer::instance().model(MODELS::USUARIOS)->get(_idUsuario);
        if (response->list().count() > 0)
            _usuario = qSharedPointerDynamicCast<Usuario>(response->list().at(0));
    }
    return _usuario;
}
Ejemplo n.º 4
0
QSharedPointer<MovimientoStock> MovimientoStock::movimientoAnterior()
{
    if ((_idMovimientoAnterior != -1) && (_movimientoAnterior.isNull()))
    {
        ResponsePtr response = ModelContainer::instance().model(MODELS::MOVIMIENTOS_STOCK)->get(_idMovimientoAnterior);
        if (response->list().count() > 0)
            _movimientoAnterior = qSharedPointerDynamicCast<MovimientoStock>(response->list().at(0));
    }

    return _movimientoAnterior;
}
    void handle_tcp_connection_info_notification(ResponsePtr notification)
    {
        assert(notification->type() == PSMoveProtocol::Response_ResponseType_CONNECTION_INFO);

        // Remember the connection id
        m_tcp_connection_id= notification->result_connection_info().tcp_connection_id();
        
        CLIENT_LOG_INFO("ClientNetworkManager::handle_tcp_connection_info_notification") 
            << "Got connection_id: " << m_tcp_connection_id << std::endl;

        // Send the connection id back to the server over UDP
        // to establish a UDP connected and associate it with the TCP connection
        send_udp_connection_id();
    }
Ejemplo n.º 6
0
void ADHttp::makeRequest(const RequestType&,
                            const std::string& url,
                            const Params&,
                            const Callback& callback)
{
    cocos2d::CCLog("HTTP is not supported on this platform: %s",
                   url.c_str());

    ResponsePtr res = std::make_shared<Response>();
    res->setCode(-100);
    res->setIsOk(false);

    callback(res);
}
Ejemplo n.º 7
0
void ADHttp::platformDownloadFile(const std::string& url,
                                  const std::string& ,
                                  const Callback& callback,
                                  const ProgressCallback& )
{
    cocos2d::CCLog("HTTP is not supported on this platform: %s",
                   url.c_str());

    ResponsePtr res = std::make_shared<Response>();
    res->setCode(-100);
    res->setIsOk(false);

    callback(res);
}
Ejemplo n.º 8
0
		void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
		{
			LLSD result;
			result["state"] = "complete";
			result["test"] = "test";
			r->result(result);
		}
    // Called when enough data was read into m_readbuf for a complete response message. 
    // Parse the response and forward it on to the response handler.
    void handle_tcp_response_received()
    {
        // No longer is there a pending read
        m_has_pending_tcp_read= false;

        // Parse the response buffer
        if (m_packed_response.unpack(m_response_read_buffer))
        {
            ResponsePtr response = m_packed_response.get_msg();

            if (response->request_id() != -1)
            {
                CLIENT_LOG_INFO("ClientNetworkManager::handle_tcp_response_received") 
                    << "Received response type " << response->type() << std::endl;
                m_response_listener->handle_response(response);
            }
            else
            {
                CLIENT_LOG_INFO("ClientNetworkManager::handle_tcp_response_received") 
                    << "Received notification type " << response->type() << std::endl;

                if (response->type() == PSMoveProtocol::Response_ResponseType_CONNECTION_INFO)
                {
                    // SPECIAL CASE: ConnectionInfo response sent at
                    handle_tcp_connection_info_notification(response);
                }
                else
                {
                    // Responses without a request ID are notifications
                    m_notification_listener->handle_notification(response);
                }
            }
        }
        else
        {
            CLIENT_LOG_ERROR("ClientNetworkManager::handle_tcp_response_received") 
                << "Error malformed response" << std::endl;
            stop();

            if (m_netEventListener)
            {
                //###bwalker $TODO pick a better error code that means "malformed data"
                m_netEventListener->handle_server_connection_socket_error(boost::asio::error::message_size);
            }
        }
    }
Ejemplo n.º 10
0
// virtual
void  LLHTTPNode::options(ResponsePtr response, const LLSD& context) const
{
	//llinfos << "options context: " << context << llendl;

	// default implementation constructs an url to the documentation.
	std::string host = context[CONTEXT_REQUEST]["headers"]["host"].asString();
	if(host.empty())
	{
		response->status(400, "Bad Request -- need Host header");
		return;
	}
	std::ostringstream ostr;
	ostr << "http://" << host << "/web/server/api";
	ostr << context[CONTEXT_REQUEST]["path"].asString();
	static const std::string DOC_HEADER("X-Documentation-URL");
	response->addHeader(DOC_HEADER, ostr.str());
	response->status(200, "OK");
}
Ejemplo n.º 11
0
ResponsePtr DatabaseSubsystem::getResponse(int responseID)
{
    RWLock::ScopedLock lock(_dbLock);

    ResponsePtr result;
    Session session = getSession();
    session.begin();
    session <<
        "SELECT * FROM response WHERE response_id = ?",
        use(responseID),
        into(result),
        now;
    if (!result.isNull()) {
        getResponseLabels(session, result);
    }
    session.commit();
    return result;
}
Ejemplo n.º 12
0
    virtual void get(ResponsePtr response, const LLSD& context) const
	{
		const LLSD& remainder = context["request"]["remainder"];
		
		if (remainder.size() > 0)
		{
			const LLHTTPNode* node = followRemainder(remainder);
			if (!node)
			{
				response->notFound();
				return;
			}
			
			Description desc;
			node->describe(desc);
			response->result(desc.getInfo());
			return;
		}

		response->result(rootNode()->allNodePaths());
	}
Ejemplo n.º 13
0
		virtual void get(ResponsePtr response, const LLSD& context) const
		{
			int n = context["extra"]["value"];
			
			LLSD info;
			info["value"] = n;
			info["positive"] = n > 0;
			info["zero"] = n == 0;
			info["negative"] = n < 0;
		
			response->result(info);
		}
Ejemplo n.º 14
0
		void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
			{ r->status(input["status"], input["reason"]); }
Ejemplo n.º 15
0
		void get(ResponsePtr r, const LLSD& context) const
			{ r->status(599, "Intentional error"); }