资源简介
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语言 报刊订阅管理系统
相关资源
- 21天学通C++第8版源代码
- c++利用遗传算法求解函数优化问题
- TXT文本里关键字检索
- 基于C++的边缘检测算法
- C++ USB HID
- vs2013 VC++项目里的Windows窗体应用程序
- C++标准库chm
- 协同过滤算法代码 C++
- socket文件传输C++
- 用c++设计一个日期类Date,包括年、月
- VC++ 实现增大可执行文件的体积 自
- c++ primer plus 第6版 中文版pdf 高清完整
- C++跑酷游戏
- C++简单的画图程序源代码
- c++ builder实现文件粉碎机的源码
- 简单电子英汉词典c++
- C++程序设计语言:第1~3部分原书第4版
- c++程序设计 谭浩强第二版答案
- c++学生信息管理系统附带报告
- C++builder编写的简单科学计算器
- C++ QT中 通过UDP广播获取网络中所有设
- 课程设计哲学家就餐问题报告+代码
- 网桥自学习算法
- 路由器分组转发算法_计算机通信课程
- C++下操作access数据库
- C++精确定时定时器
- c++链表队列的实现
- 快速Hartley变换C++实现
- 停车场管理问题 C++/C数据结构
- C++课设高校人员信息管理系统.doc
评论
共有 条评论