资源简介
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语言 报刊订阅管理系统
相关资源
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
- c++ 虚拟摄像头
- hook,捕获所有案件,查找所有窗口,
- C语言课设计算器
- c++ 简易贪吃蛇源码
- 高精度加法(c++代码)
- C++调用百度地图案例
- 北京化工大学计算方法(C/C++)讲义
- 基于VC++的SolidWorks二次开发SolidWorks
- c++ 模拟鼠标按键
- OFD编辑器
- Beginning C++17 From Novice to Professional
- C++ STL实现
- opencv手部轮廓识别以及轨迹识别
- 百度C++编码规范
- C++ sql2008 WebServer通讯.docx
- c++ 定时关机程序源码
- 基于VSCode和CMake实现C++开发
- c++语法查询工具
- c++ 账务系统源码
- GBT 28169-2011 嵌入式软件 C语言编码规范
- c++ 猜拳小游戏
- XUnZip Zip解压缩.rar
评论
共有 条评论