Loading...
Searching...
No Matches
delivery_token.h
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v20.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Frank Pagliughi - initial implementation and documentation
*******************************************************************************/
#ifndef __mqtt_delivery_token_h
#define __mqtt_delivery_token_h
#include <memory>
#include "MQTTAsync.h"
#include "mqtt/message.h"
#include "mqtt/token.h"
namespace mqtt {
class delivery_token : public token
{
const_message_ptr msg_;
friend class async_client;
void set_message(const_message_ptr msg) { msg_ = msg; }
public:
using ptr_t = std::shared_ptr<delivery_token>;
using const_ptr_t = std::shared_ptr<delivery_token>;
using weak_ptr_t = std::weak_ptr<delivery_token>;
delivery_token(iasync_client& cli) : token(token::Type::PUBLISH, cli) {}
delivery_token(iasync_client& cli, const_message_ptr msg)
: token(token::Type::PUBLISH, cli, msg->get_topic()), msg_(std::move(msg)) {}
delivery_token(
iasync_client& cli, const_message_ptr msg, void* userContext, iaction_listener& cb
)
: token(token::Type::PUBLISH, cli, msg->get_topic(), userContext, cb),
msg_(std::move(msg)) {}
static ptr_t create(iasync_client& cli) { return std::make_shared<delivery_token>(cli); }
static ptr_t create(iasync_client& cli, const_message_ptr msg) {
return std::make_shared<delivery_token>(cli, msg);
}
static ptr_t create(
iasync_client& cli, const_message_ptr msg, void* userContext, iaction_listener& cb
) {
return std::make_shared<delivery_token>(cli, msg, userContext, cb);
}
virtual const_message_ptr get_message() const { return msg_; }
};
using delivery_token_ptr = delivery_token::ptr_t;
using const_delivery_token_ptr = delivery_token::const_ptr_t;
} // namespace mqtt
#endif // __mqtt_delivery_token_h
mqtt::async_client
Definition async_client.h:137
mqtt::delivery_token
Definition delivery_token.h:43
mqtt::delivery_token::delivery_token
delivery_token(iasync_client &cli)
Definition delivery_token.h:68
mqtt::delivery_token::create
static ptr_t create(iasync_client &cli, const_message_ptr msg)
Definition delivery_token.h:101
mqtt::delivery_token::delivery_token
delivery_token(iasync_client &cli, const_message_ptr msg, void *userContext, iaction_listener &cb)
Definition delivery_token.h:86
mqtt::delivery_token::get_message
virtual const_message_ptr get_message() const
Definition delivery_token.h:123
mqtt::delivery_token::create
static ptr_t create(iasync_client &cli)
Definition delivery_token.h:95
mqtt::delivery_token::create
static ptr_t create(iasync_client &cli, const_message_ptr msg, void *userContext, iaction_listener &cb)
Definition delivery_token.h:114
mqtt::delivery_token::ptr_t
std::shared_ptr< delivery_token > ptr_t
Definition delivery_token.h:58
mqtt::delivery_token::const_ptr_t
std::shared_ptr< delivery_token > const_ptr_t
Definition delivery_token.h:60
mqtt::delivery_token::delivery_token
delivery_token(iasync_client &cli, const_message_ptr msg)
Definition delivery_token.h:74
mqtt::delivery_token::weak_ptr_t
std::weak_ptr< delivery_token > weak_ptr_t
Definition delivery_token.h:62
mqtt::iaction_listener
Definition iaction_listener.h:50
mqtt::iasync_client
Definition iasync_client.h:60
mqtt::token
Definition token.h:54
mqtt::token::Type
Type
Definition token.h:64
mqtt::token::PUBLISH
@ PUBLISH
Definition token.h:64
message.h
mqtt
Definition async_client.h:60
mqtt::const_delivery_token_ptr
delivery_token::const_ptr_t const_delivery_token_ptr
Definition delivery_token.h:130
mqtt::const_message_ptr
message::const_ptr_t const_message_ptr
Definition message.h:372
mqtt::delivery_token_ptr
delivery_token::ptr_t delivery_token_ptr
Definition delivery_token.h:127
token.h