Support session query operations.

This commit is contained in:
sdk-team
2020-08-18 10:40:40 +08:00
parent 2e76d1dcac
commit 06eedce285
17 changed files with 791 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
2020-08-18 Version: 1.36.597
- Support session query operations.
2020-08-18 Version: 1.36.596
- Public beta version.
- Add Api Overseas.

View File

@@ -1 +1 @@
1.36.596
1.36.597

View File

@@ -23,31 +23,43 @@ set(onsmqtt_public_header
set(onsmqtt_public_header_model
include/alibabacloud/onsmqtt/model/ApplyTokenRequest.h
include/alibabacloud/onsmqtt/model/ApplyTokenResult.h
include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h
include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h
include/alibabacloud/onsmqtt/model/CreateGroupIdRequest.h
include/alibabacloud/onsmqtt/model/CreateGroupIdResult.h
include/alibabacloud/onsmqtt/model/DeleteGroupIdRequest.h
include/alibabacloud/onsmqtt/model/DeleteGroupIdResult.h
include/alibabacloud/onsmqtt/model/ListGroupIdRequest.h
include/alibabacloud/onsmqtt/model/ListGroupIdResult.h
include/alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h
include/alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h
include/alibabacloud/onsmqtt/model/QueryTokenRequest.h
include/alibabacloud/onsmqtt/model/QueryTokenResult.h
include/alibabacloud/onsmqtt/model/RevokeTokenRequest.h
include/alibabacloud/onsmqtt/model/RevokeTokenResult.h )
include/alibabacloud/onsmqtt/model/RevokeTokenResult.h
include/alibabacloud/onsmqtt/model/SendMessageRequest.h
include/alibabacloud/onsmqtt/model/SendMessageResult.h )
set(onsmqtt_src
src/OnsMqttClient.cc
src/model/ApplyTokenRequest.cc
src/model/ApplyTokenResult.cc
src/model/BatchQuerySessionByClientIdsRequest.cc
src/model/BatchQuerySessionByClientIdsResult.cc
src/model/CreateGroupIdRequest.cc
src/model/CreateGroupIdResult.cc
src/model/DeleteGroupIdRequest.cc
src/model/DeleteGroupIdResult.cc
src/model/ListGroupIdRequest.cc
src/model/ListGroupIdResult.cc
src/model/QuerySessionByClientIdRequest.cc
src/model/QuerySessionByClientIdResult.cc
src/model/QueryTokenRequest.cc
src/model/QueryTokenResult.cc
src/model/RevokeTokenRequest.cc
src/model/RevokeTokenResult.cc )
src/model/RevokeTokenResult.cc
src/model/SendMessageRequest.cc
src/model/SendMessageResult.cc )
add_library(onsmqtt ${LIB_TYPE}
${onsmqtt_public_header}

View File

@@ -24,16 +24,22 @@
#include "OnsMqttExport.h"
#include "model/ApplyTokenRequest.h"
#include "model/ApplyTokenResult.h"
#include "model/BatchQuerySessionByClientIdsRequest.h"
#include "model/BatchQuerySessionByClientIdsResult.h"
#include "model/CreateGroupIdRequest.h"
#include "model/CreateGroupIdResult.h"
#include "model/DeleteGroupIdRequest.h"
#include "model/DeleteGroupIdResult.h"
#include "model/ListGroupIdRequest.h"
#include "model/ListGroupIdResult.h"
#include "model/QuerySessionByClientIdRequest.h"
#include "model/QuerySessionByClientIdResult.h"
#include "model/QueryTokenRequest.h"
#include "model/QueryTokenResult.h"
#include "model/RevokeTokenRequest.h"
#include "model/RevokeTokenResult.h"
#include "model/SendMessageRequest.h"
#include "model/SendMessageResult.h"
namespace AlibabaCloud
@@ -46,6 +52,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::ApplyTokenResult> ApplyTokenOutcome;
typedef std::future<ApplyTokenOutcome> ApplyTokenOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::ApplyTokenRequest&, const ApplyTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ApplyTokenAsyncHandler;
typedef Outcome<Error, Model::BatchQuerySessionByClientIdsResult> BatchQuerySessionByClientIdsOutcome;
typedef std::future<BatchQuerySessionByClientIdsOutcome> BatchQuerySessionByClientIdsOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::BatchQuerySessionByClientIdsRequest&, const BatchQuerySessionByClientIdsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> BatchQuerySessionByClientIdsAsyncHandler;
typedef Outcome<Error, Model::CreateGroupIdResult> CreateGroupIdOutcome;
typedef std::future<CreateGroupIdOutcome> CreateGroupIdOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::CreateGroupIdRequest&, const CreateGroupIdOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateGroupIdAsyncHandler;
@@ -55,12 +64,18 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::ListGroupIdResult> ListGroupIdOutcome;
typedef std::future<ListGroupIdOutcome> ListGroupIdOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::ListGroupIdRequest&, const ListGroupIdOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListGroupIdAsyncHandler;
typedef Outcome<Error, Model::QuerySessionByClientIdResult> QuerySessionByClientIdOutcome;
typedef std::future<QuerySessionByClientIdOutcome> QuerySessionByClientIdOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::QuerySessionByClientIdRequest&, const QuerySessionByClientIdOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> QuerySessionByClientIdAsyncHandler;
typedef Outcome<Error, Model::QueryTokenResult> QueryTokenOutcome;
typedef std::future<QueryTokenOutcome> QueryTokenOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::QueryTokenRequest&, const QueryTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> QueryTokenAsyncHandler;
typedef Outcome<Error, Model::RevokeTokenResult> RevokeTokenOutcome;
typedef std::future<RevokeTokenOutcome> RevokeTokenOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::RevokeTokenRequest&, const RevokeTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RevokeTokenAsyncHandler;
typedef Outcome<Error, Model::SendMessageResult> SendMessageOutcome;
typedef std::future<SendMessageOutcome> SendMessageOutcomeCallable;
typedef std::function<void(const OnsMqttClient*, const Model::SendMessageRequest&, const SendMessageOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SendMessageAsyncHandler;
OnsMqttClient(const Credentials &credentials, const ClientConfiguration &configuration);
OnsMqttClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
@@ -69,6 +84,9 @@ namespace AlibabaCloud
ApplyTokenOutcome applyToken(const Model::ApplyTokenRequest &request)const;
void applyTokenAsync(const Model::ApplyTokenRequest& request, const ApplyTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ApplyTokenOutcomeCallable applyTokenCallable(const Model::ApplyTokenRequest& request) const;
BatchQuerySessionByClientIdsOutcome batchQuerySessionByClientIds(const Model::BatchQuerySessionByClientIdsRequest &request)const;
void batchQuerySessionByClientIdsAsync(const Model::BatchQuerySessionByClientIdsRequest& request, const BatchQuerySessionByClientIdsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
BatchQuerySessionByClientIdsOutcomeCallable batchQuerySessionByClientIdsCallable(const Model::BatchQuerySessionByClientIdsRequest& request) const;
CreateGroupIdOutcome createGroupId(const Model::CreateGroupIdRequest &request)const;
void createGroupIdAsync(const Model::CreateGroupIdRequest& request, const CreateGroupIdAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateGroupIdOutcomeCallable createGroupIdCallable(const Model::CreateGroupIdRequest& request) const;
@@ -78,12 +96,18 @@ namespace AlibabaCloud
ListGroupIdOutcome listGroupId(const Model::ListGroupIdRequest &request)const;
void listGroupIdAsync(const Model::ListGroupIdRequest& request, const ListGroupIdAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListGroupIdOutcomeCallable listGroupIdCallable(const Model::ListGroupIdRequest& request) const;
QuerySessionByClientIdOutcome querySessionByClientId(const Model::QuerySessionByClientIdRequest &request)const;
void querySessionByClientIdAsync(const Model::QuerySessionByClientIdRequest& request, const QuerySessionByClientIdAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
QuerySessionByClientIdOutcomeCallable querySessionByClientIdCallable(const Model::QuerySessionByClientIdRequest& request) const;
QueryTokenOutcome queryToken(const Model::QueryTokenRequest &request)const;
void queryTokenAsync(const Model::QueryTokenRequest& request, const QueryTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
QueryTokenOutcomeCallable queryTokenCallable(const Model::QueryTokenRequest& request) const;
RevokeTokenOutcome revokeToken(const Model::RevokeTokenRequest &request)const;
void revokeTokenAsync(const Model::RevokeTokenRequest& request, const RevokeTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
RevokeTokenOutcomeCallable revokeTokenCallable(const Model::RevokeTokenRequest& request) const;
SendMessageOutcome sendMessage(const Model::SendMessageRequest &request)const;
void sendMessageAsync(const Model::SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SendMessageOutcomeCallable sendMessageCallable(const Model::SendMessageRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSREQUEST_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT BatchQuerySessionByClientIdsRequest : public RpcServiceRequest
{
public:
BatchQuerySessionByClientIdsRequest();
~BatchQuerySessionByClientIdsRequest();
std::vector<std::string> getClientIdList()const;
void setClientIdList(const std::vector<std::string>& clientIdList);
std::string getInstanceId()const;
void setInstanceId(const std::string& instanceId);
private:
std::vector<std::string> clientIdList_;
std::string instanceId_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSREQUEST_H_

View File

@@ -0,0 +1,56 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSRESULT_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT BatchQuerySessionByClientIdsResult : public ServiceResult
{
public:
struct OnlineStatusListItem
{
bool onlineStatus;
std::string clientId;
};
BatchQuerySessionByClientIdsResult();
explicit BatchQuerySessionByClientIdsResult(const std::string &payload);
~BatchQuerySessionByClientIdsResult();
std::vector<OnlineStatusListItem> getOnlineStatusList()const;
protected:
void parse(const std::string &payload);
private:
std::vector<OnlineStatusListItem> onlineStatusList_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSRESULT_H_

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDREQUEST_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT QuerySessionByClientIdRequest : public RpcServiceRequest
{
public:
QuerySessionByClientIdRequest();
~QuerySessionByClientIdRequest();
std::string getClientId()const;
void setClientId(const std::string& clientId);
std::string getInstanceId()const;
void setInstanceId(const std::string& instanceId);
private:
std::string clientId_;
std::string instanceId_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDREQUEST_H_

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDRESULT_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT QuerySessionByClientIdResult : public ServiceResult
{
public:
QuerySessionByClientIdResult();
explicit QuerySessionByClientIdResult(const std::string &payload);
~QuerySessionByClientIdResult();
bool getOnlineStatus()const;
protected:
void parse(const std::string &payload);
private:
bool onlineStatus_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_QUERYSESSIONBYCLIENTIDRESULT_H_

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGEREQUEST_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGEREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT SendMessageRequest : public RpcServiceRequest
{
public:
SendMessageRequest();
~SendMessageRequest();
std::string getMqttTopic()const;
void setMqttTopic(const std::string& mqttTopic);
std::string getInstanceId()const;
void setInstanceId(const std::string& instanceId);
std::string getPayload()const;
void setPayload(const std::string& payload);
private:
std::string mqttTopic_;
std::string instanceId_;
std::string payload_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGEREQUEST_H_

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGERESULT_H_
#define ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/onsmqtt/OnsMqttExport.h>
namespace AlibabaCloud
{
namespace OnsMqtt
{
namespace Model
{
class ALIBABACLOUD_ONSMQTT_EXPORT SendMessageResult : public ServiceResult
{
public:
SendMessageResult();
explicit SendMessageResult(const std::string &payload);
~SendMessageResult();
std::string getMsgId()const;
protected:
void parse(const std::string &payload);
private:
std::string msgId_;
};
}
}
}
#endif // !ALIBABACLOUD_ONSMQTT_MODEL_SENDMESSAGERESULT_H_

View File

@@ -87,6 +87,42 @@ OnsMqttClient::ApplyTokenOutcomeCallable OnsMqttClient::applyTokenCallable(const
return task->get_future();
}
OnsMqttClient::BatchQuerySessionByClientIdsOutcome OnsMqttClient::batchQuerySessionByClientIds(const BatchQuerySessionByClientIdsRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return BatchQuerySessionByClientIdsOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return BatchQuerySessionByClientIdsOutcome(BatchQuerySessionByClientIdsResult(outcome.result()));
else
return BatchQuerySessionByClientIdsOutcome(outcome.error());
}
void OnsMqttClient::batchQuerySessionByClientIdsAsync(const BatchQuerySessionByClientIdsRequest& request, const BatchQuerySessionByClientIdsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, batchQuerySessionByClientIds(request), context);
};
asyncExecute(new Runnable(fn));
}
OnsMqttClient::BatchQuerySessionByClientIdsOutcomeCallable OnsMqttClient::batchQuerySessionByClientIdsCallable(const BatchQuerySessionByClientIdsRequest &request) const
{
auto task = std::make_shared<std::packaged_task<BatchQuerySessionByClientIdsOutcome()>>(
[this, request]()
{
return this->batchQuerySessionByClientIds(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
OnsMqttClient::CreateGroupIdOutcome OnsMqttClient::createGroupId(const CreateGroupIdRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -195,6 +231,42 @@ OnsMqttClient::ListGroupIdOutcomeCallable OnsMqttClient::listGroupIdCallable(con
return task->get_future();
}
OnsMqttClient::QuerySessionByClientIdOutcome OnsMqttClient::querySessionByClientId(const QuerySessionByClientIdRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return QuerySessionByClientIdOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return QuerySessionByClientIdOutcome(QuerySessionByClientIdResult(outcome.result()));
else
return QuerySessionByClientIdOutcome(outcome.error());
}
void OnsMqttClient::querySessionByClientIdAsync(const QuerySessionByClientIdRequest& request, const QuerySessionByClientIdAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, querySessionByClientId(request), context);
};
asyncExecute(new Runnable(fn));
}
OnsMqttClient::QuerySessionByClientIdOutcomeCallable OnsMqttClient::querySessionByClientIdCallable(const QuerySessionByClientIdRequest &request) const
{
auto task = std::make_shared<std::packaged_task<QuerySessionByClientIdOutcome()>>(
[this, request]()
{
return this->querySessionByClientId(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
OnsMqttClient::QueryTokenOutcome OnsMqttClient::queryToken(const QueryTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -267,3 +339,39 @@ OnsMqttClient::RevokeTokenOutcomeCallable OnsMqttClient::revokeTokenCallable(con
return task->get_future();
}
OnsMqttClient::SendMessageOutcome OnsMqttClient::sendMessage(const SendMessageRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return SendMessageOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return SendMessageOutcome(SendMessageResult(outcome.result()));
else
return SendMessageOutcome(outcome.error());
}
void OnsMqttClient::sendMessageAsync(const SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, sendMessage(request), context);
};
asyncExecute(new Runnable(fn));
}
OnsMqttClient::SendMessageOutcomeCallable OnsMqttClient::sendMessageCallable(const SendMessageRequest &request) const
{
auto task = std::make_shared<std::packaged_task<SendMessageOutcome()>>(
[this, request]()
{
return this->sendMessage(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h>
using AlibabaCloud::OnsMqtt::Model::BatchQuerySessionByClientIdsRequest;
BatchQuerySessionByClientIdsRequest::BatchQuerySessionByClientIdsRequest() :
RpcServiceRequest("onsmqtt", "2020-04-20", "BatchQuerySessionByClientIds")
{
setMethod(HttpRequest::Method::Post);
}
BatchQuerySessionByClientIdsRequest::~BatchQuerySessionByClientIdsRequest()
{}
std::vector<std::string> BatchQuerySessionByClientIdsRequest::getClientIdList()const
{
return clientIdList_;
}
void BatchQuerySessionByClientIdsRequest::setClientIdList(const std::vector<std::string>& clientIdList)
{
clientIdList_ = clientIdList;
for(int dep1 = 0; dep1!= clientIdList.size(); dep1++) {
setParameter("ClientIdList."+ std::to_string(dep1), clientIdList.at(dep1));
}
}
std::string BatchQuerySessionByClientIdsRequest::getInstanceId()const
{
return instanceId_;
}
void BatchQuerySessionByClientIdsRequest::setInstanceId(const std::string& instanceId)
{
instanceId_ = instanceId;
setParameter("InstanceId", instanceId);
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h>
#include <json/json.h>
using namespace AlibabaCloud::OnsMqtt;
using namespace AlibabaCloud::OnsMqtt::Model;
BatchQuerySessionByClientIdsResult::BatchQuerySessionByClientIdsResult() :
ServiceResult()
{}
BatchQuerySessionByClientIdsResult::BatchQuerySessionByClientIdsResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
BatchQuerySessionByClientIdsResult::~BatchQuerySessionByClientIdsResult()
{}
void BatchQuerySessionByClientIdsResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allOnlineStatusListNode = value["OnlineStatusList"]["OnlineStatusListItem"];
for (auto valueOnlineStatusListOnlineStatusListItem : allOnlineStatusListNode)
{
OnlineStatusListItem onlineStatusListObject;
if(!valueOnlineStatusListOnlineStatusListItem["ClientId"].isNull())
onlineStatusListObject.clientId = valueOnlineStatusListOnlineStatusListItem["ClientId"].asString();
if(!valueOnlineStatusListOnlineStatusListItem["OnlineStatus"].isNull())
onlineStatusListObject.onlineStatus = valueOnlineStatusListOnlineStatusListItem["OnlineStatus"].asString() == "true";
onlineStatusList_.push_back(onlineStatusListObject);
}
}
std::vector<BatchQuerySessionByClientIdsResult::OnlineStatusListItem> BatchQuerySessionByClientIdsResult::getOnlineStatusList()const
{
return onlineStatusList_;
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h>
using AlibabaCloud::OnsMqtt::Model::QuerySessionByClientIdRequest;
QuerySessionByClientIdRequest::QuerySessionByClientIdRequest() :
RpcServiceRequest("onsmqtt", "2020-04-20", "QuerySessionByClientId")
{
setMethod(HttpRequest::Method::Post);
}
QuerySessionByClientIdRequest::~QuerySessionByClientIdRequest()
{}
std::string QuerySessionByClientIdRequest::getClientId()const
{
return clientId_;
}
void QuerySessionByClientIdRequest::setClientId(const std::string& clientId)
{
clientId_ = clientId;
setParameter("ClientId", clientId);
}
std::string QuerySessionByClientIdRequest::getInstanceId()const
{
return instanceId_;
}
void QuerySessionByClientIdRequest::setInstanceId(const std::string& instanceId)
{
instanceId_ = instanceId;
setParameter("InstanceId", instanceId);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h>
#include <json/json.h>
using namespace AlibabaCloud::OnsMqtt;
using namespace AlibabaCloud::OnsMqtt::Model;
QuerySessionByClientIdResult::QuerySessionByClientIdResult() :
ServiceResult()
{}
QuerySessionByClientIdResult::QuerySessionByClientIdResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
QuerySessionByClientIdResult::~QuerySessionByClientIdResult()
{}
void QuerySessionByClientIdResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["OnlineStatus"].isNull())
onlineStatus_ = value["OnlineStatus"].asString() == "true";
}
bool QuerySessionByClientIdResult::getOnlineStatus()const
{
return onlineStatus_;
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/SendMessageRequest.h>
using AlibabaCloud::OnsMqtt::Model::SendMessageRequest;
SendMessageRequest::SendMessageRequest() :
RpcServiceRequest("onsmqtt", "2020-04-20", "SendMessage")
{
setMethod(HttpRequest::Method::Post);
}
SendMessageRequest::~SendMessageRequest()
{}
std::string SendMessageRequest::getMqttTopic()const
{
return mqttTopic_;
}
void SendMessageRequest::setMqttTopic(const std::string& mqttTopic)
{
mqttTopic_ = mqttTopic;
setParameter("MqttTopic", mqttTopic);
}
std::string SendMessageRequest::getInstanceId()const
{
return instanceId_;
}
void SendMessageRequest::setInstanceId(const std::string& instanceId)
{
instanceId_ = instanceId;
setParameter("InstanceId", instanceId);
}
std::string SendMessageRequest::getPayload()const
{
return payload_;
}
void SendMessageRequest::setPayload(const std::string& payload)
{
payload_ = payload;
setParameter("Payload", payload);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/onsmqtt/model/SendMessageResult.h>
#include <json/json.h>
using namespace AlibabaCloud::OnsMqtt;
using namespace AlibabaCloud::OnsMqtt::Model;
SendMessageResult::SendMessageResult() :
ServiceResult()
{}
SendMessageResult::SendMessageResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
SendMessageResult::~SendMessageResult()
{}
void SendMessageResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["MsgId"].isNull())
msgId_ = value["MsgId"].asString();
}
std::string SendMessageResult::getMsgId()const
{
return msgId_;
}