Exemplo n.º 1
0
	void response_base< Timer >::handle_request( const json::object& request,
	    const boost::shared_ptr< response_interface >& self, const std::string& connection_name, bool last_message )
	{
		const json::string channel = extract_channel( request );

		if ( channel == meta_handshake_channel )
		{
			handle_handshake( request, connection_name );
			return;
		}

		const json::string client_id = check_client_id( request, channel );
		if ( client_id.empty() )
		    return;

		if ( !check_session( request, client_id, channel ) )
		    return;

        if ( channel == meta_connect_channel )
        {
            handle_connect( request, self, last_message );
        }
        else if ( channel == meta_disconnect_channel )
        {
            handle_disconnect( request );
        }
        else if ( channel == meta_subscribe_channel )
        {
            handle_subscribe( request );
        }
        else if ( channel == meta_unsubscribe_channel )
        {
            handle_unsubscribe( request );
        }
        else
        {
            handle_publish( channel, request );
        }
	}
Exemplo n.º 2
0
int broker_msg_handle_subscribe(RemoteDSLink *link, json_t *req) {
    broker_utils_send_closed_resp(link, req, NULL);

    json_t *paths = json_object_get(req, "paths");
    if (!json_is_array(paths)) {
        return 1;
    }


    json_t *maxPermitJson = json_object_get(req, "permit");
    PermissionLevel maxPermit = PERMISSION_CONFIG;
    if (json_is_string(maxPermitJson)) {
        maxPermit = permission_str_level(json_string_value(maxPermitJson));
    }

    if (maxPermit < PERMISSION_READ) {
        return 0;
    }

    size_t index;
    json_t *obj;
    json_array_foreach(paths, index, obj) {
        handle_subscribe(link, obj);
    }