资源简介
C++实现mqtt协议:官网的mqtt c++实现,个觉得写得非常棒!
代码片段和文件信息
//async_client.cpp
/*******************************************************************************
* Copyright (c) 2013 Frank Pagliughi
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.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
*******************************************************************************/
#include “mqtt/async_client.h“
#include “mqtt/token.h“
#include “mqtt/message.h“
#include
#include
#include
#include
#include
#include
namespace mqtt {
/////////////////////////////////////////////////////////////////////////////
async_client::async_client(const std::string& serverURI const std::string& clientId)
: serverURI_(serverURI) clientId_(clientId)
persist_(nullptr) userCallback_(nullptr)
{
MQTTAsync_create(&cli_ const_cast(serverURI.c_str())
const_cast(clientId.c_str())
MQTTCLIENT_PERSISTENCE_DEFAULT nullptr);
}
async_client::async_client(const std::string& serverURI const std::string& clientId
const std::string& persistDir)
: serverURI_(serverURI) clientId_(clientId)
persist_(nullptr) userCallback_(nullptr)
{
MQTTAsync_create(&cli_ const_cast(serverURI.c_str())
const_cast(clientId.c_str())
MQTTCLIENT_PERSISTENCE_DEFAULT
const_cast(persistDir.c_str()));
}
async_client::async_client(const std::string& serverURI const std::string& clientId
iclient_persistence* persistence)
: serverURI_(serverURI) clientId_(clientId)
persist_(nullptr) userCallback_(nullptr)
{
if (!persistence) {
MQTTAsync_create(&cli_ const_cast(serverURI.c_str())
const_cast(clientId.c_str())
MQTTCLIENT_PERSISTENCE_NONE nullptr);
}
else {
persist_ = new MQTTClient_persistence {
persistence
&iclient_persistence::persistence_open
&iclient_persistence::persistence_close
&iclient_persistence::persistence_put
&iclient_persistence::persistence_get
&iclient_persistence::persistence_remove
&iclient_persistence::persistence_keys
&iclient_persistence::persistence_clear
&iclient_persistence::persistence_containskey
};
MQTTAsync_create(&cli_ const_cast(serverURI.c_str())
const_cast(clientId.c_str())
MQTTCLIENT_PERSISTENCE_USER persist_);
}
}
async_client::~async_client()
{
MQTTAsync_destroy(&cli_);
delete persist_;
}
// --------------------------------------------------------------------------
void async_client 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\
文件 1853 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\CONTRIBUTING.md
文件 2935 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\Makefile
文件 873 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\README.md
文件 1605 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\about.html
目录 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\doc\
文件 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\doc\.include
文件 75583 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\doc\Doxyfile
文件 1564 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\edl-v10
文件 11232 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\epl-v10
文件 9230 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\notice.html
目录 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\
文件 17688 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\async_client.cpp
文件 4088 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\client.cpp
文件 6327 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\iclient_persistence.cpp
文件 2972 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\message.cpp
目录 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\
文件 18963 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\async_client.h
文件 2173 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\callback.h
文件 6689 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\client.h
文件 5354 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\connect_options.h
文件 3114 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\delivery_token.h
文件 3165 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\exception.h
文件 2586 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\iaction_listener.h
文件 4473 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\iclient_persistence.h
文件 4559 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\ipersistable.h
文件 5049 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\message.h
文件 9387 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\token.h
文件 3032 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\mqtt\topic.h
目录 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\obj\
文件 0 2014-04-04 08:43 org.eclipse.paho.mqtt.cpp-55216695b73dc7ab2a9f917878de2b8eddb7c474\src\obj\async_client.dep
............此处省略12个文件信息
- 上一篇:TFTP_C程序实现
- 下一篇:C语言 报刊订阅管理系统
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 物联网GPS跟踪器demo程序
- STM32连接EC20使用内置MQTT协议接入阿里
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
川公网安备 51152502000135号
评论
共有 条评论