From 06eedce285b1316e0982721bf7fafbbff37727a3 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Tue, 18 Aug 2020 10:40:40 +0800 Subject: [PATCH] Support session query operations. --- CHANGELOG | 3 + VERSION | 2 +- onsmqtt/CMakeLists.txt | 16 ++- .../alibabacloud/onsmqtt/OnsMqttClient.h | 24 ++++ .../BatchQuerySessionByClientIdsRequest.h | 51 +++++++++ .../BatchQuerySessionByClientIdsResult.h | 56 +++++++++ .../model/QuerySessionByClientIdRequest.h | 51 +++++++++ .../model/QuerySessionByClientIdResult.h | 51 +++++++++ .../onsmqtt/model/SendMessageRequest.h | 54 +++++++++ .../onsmqtt/model/SendMessageResult.h | 51 +++++++++ onsmqtt/src/OnsMqttClient.cc | 108 ++++++++++++++++++ .../BatchQuerySessionByClientIdsRequest.cc | 53 +++++++++ .../BatchQuerySessionByClientIdsResult.cc | 59 ++++++++++ .../model/QuerySessionByClientIdRequest.cc | 51 +++++++++ .../src/model/QuerySessionByClientIdResult.cc | 51 +++++++++ onsmqtt/src/model/SendMessageRequest.cc | 62 ++++++++++ onsmqtt/src/model/SendMessageResult.cc | 51 +++++++++ 17 files changed, 791 insertions(+), 3 deletions(-) create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageRequest.h create mode 100644 onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageResult.h create mode 100644 onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc create mode 100644 onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc create mode 100644 onsmqtt/src/model/QuerySessionByClientIdRequest.cc create mode 100644 onsmqtt/src/model/QuerySessionByClientIdResult.cc create mode 100644 onsmqtt/src/model/SendMessageRequest.cc create mode 100644 onsmqtt/src/model/SendMessageResult.cc diff --git a/CHANGELOG b/CHANGELOG index b47b64377..f7179c787 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/VERSION b/VERSION index 66c382635..51df198bb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.596 \ No newline at end of file +1.36.597 \ No newline at end of file diff --git a/onsmqtt/CMakeLists.txt b/onsmqtt/CMakeLists.txt index c56a67799..1b105fbc6 100644 --- a/onsmqtt/CMakeLists.txt +++ b/onsmqtt/CMakeLists.txt @@ -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} diff --git a/onsmqtt/include/alibabacloud/onsmqtt/OnsMqttClient.h b/onsmqtt/include/alibabacloud/onsmqtt/OnsMqttClient.h index 9f791cb6a..93fcecb0e 100644 --- a/onsmqtt/include/alibabacloud/onsmqtt/OnsMqttClient.h +++ b/onsmqtt/include/alibabacloud/onsmqtt/OnsMqttClient.h @@ -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 ApplyTokenOutcome; typedef std::future ApplyTokenOutcomeCallable; typedef std::function&)> ApplyTokenAsyncHandler; + typedef Outcome BatchQuerySessionByClientIdsOutcome; + typedef std::future BatchQuerySessionByClientIdsOutcomeCallable; + typedef std::function&)> BatchQuerySessionByClientIdsAsyncHandler; typedef Outcome CreateGroupIdOutcome; typedef std::future CreateGroupIdOutcomeCallable; typedef std::function&)> CreateGroupIdAsyncHandler; @@ -55,12 +64,18 @@ namespace AlibabaCloud typedef Outcome ListGroupIdOutcome; typedef std::future ListGroupIdOutcomeCallable; typedef std::function&)> ListGroupIdAsyncHandler; + typedef Outcome QuerySessionByClientIdOutcome; + typedef std::future QuerySessionByClientIdOutcomeCallable; + typedef std::function&)> QuerySessionByClientIdAsyncHandler; typedef Outcome QueryTokenOutcome; typedef std::future QueryTokenOutcomeCallable; typedef std::function&)> QueryTokenAsyncHandler; typedef Outcome RevokeTokenOutcome; typedef std::future RevokeTokenOutcomeCallable; typedef std::function&)> RevokeTokenAsyncHandler; + typedef Outcome SendMessageOutcome; + typedef std::future SendMessageOutcomeCallable; + typedef std::function&)> SendMessageAsyncHandler; OnsMqttClient(const Credentials &credentials, const ClientConfiguration &configuration); OnsMqttClient(const std::shared_ptr &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& 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& 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& 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& 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& 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& 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& 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& context = nullptr) const; + SendMessageOutcomeCallable sendMessageCallable(const Model::SendMessageRequest& request) const; private: std::shared_ptr endpointProvider_; diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h b/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h new file mode 100644 index 000000000..a1420779c --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsRequest.h @@ -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 +#include +#include +#include + +namespace AlibabaCloud +{ + namespace OnsMqtt + { + namespace Model + { + class ALIBABACLOUD_ONSMQTT_EXPORT BatchQuerySessionByClientIdsRequest : public RpcServiceRequest + { + + public: + BatchQuerySessionByClientIdsRequest(); + ~BatchQuerySessionByClientIdsRequest(); + + std::vector getClientIdList()const; + void setClientIdList(const std::vector& clientIdList); + std::string getInstanceId()const; + void setInstanceId(const std::string& instanceId); + + private: + std::vector clientIdList_; + std::string instanceId_; + + }; + } + } +} +#endif // !ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSREQUEST_H_ \ No newline at end of file diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h b/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h new file mode 100644 index 000000000..8fab27c2a --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/BatchQuerySessionByClientIdsResult.h @@ -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 +#include +#include +#include +#include + +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 getOnlineStatusList()const; + + protected: + void parse(const std::string &payload); + private: + std::vector onlineStatusList_; + + }; + } + } +} +#endif // !ALIBABACLOUD_ONSMQTT_MODEL_BATCHQUERYSESSIONBYCLIENTIDSRESULT_H_ \ No newline at end of file diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h b/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h new file mode 100644 index 000000000..c8a2aa92d --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdRequest.h @@ -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 +#include +#include +#include + +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_ \ No newline at end of file diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h b/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h new file mode 100644 index 000000000..569df5fc9 --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/QuerySessionByClientIdResult.h @@ -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 +#include +#include +#include +#include + +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_ \ No newline at end of file diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageRequest.h b/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageRequest.h new file mode 100644 index 000000000..06f6d0d1a --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageRequest.h @@ -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 +#include +#include +#include + +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_ \ No newline at end of file diff --git a/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageResult.h b/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageResult.h new file mode 100644 index 000000000..ce574385c --- /dev/null +++ b/onsmqtt/include/alibabacloud/onsmqtt/model/SendMessageResult.h @@ -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 +#include +#include +#include +#include + +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_ \ No newline at end of file diff --git a/onsmqtt/src/OnsMqttClient.cc b/onsmqtt/src/OnsMqttClient.cc index 0302217c2..39ad56f9b 100644 --- a/onsmqtt/src/OnsMqttClient.cc +++ b/onsmqtt/src/OnsMqttClient.cc @@ -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& 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>( + [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& 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>( + [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& 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>( + [this, request]() + { + return this->sendMessage(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc b/onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc new file mode 100644 index 000000000..f5febc5df --- /dev/null +++ b/onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc @@ -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 + +using AlibabaCloud::OnsMqtt::Model::BatchQuerySessionByClientIdsRequest; + +BatchQuerySessionByClientIdsRequest::BatchQuerySessionByClientIdsRequest() : + RpcServiceRequest("onsmqtt", "2020-04-20", "BatchQuerySessionByClientIds") +{ + setMethod(HttpRequest::Method::Post); +} + +BatchQuerySessionByClientIdsRequest::~BatchQuerySessionByClientIdsRequest() +{} + +std::vector BatchQuerySessionByClientIdsRequest::getClientIdList()const +{ + return clientIdList_; +} + +void BatchQuerySessionByClientIdsRequest::setClientIdList(const std::vector& 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); +} + diff --git a/onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc b/onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc new file mode 100644 index 000000000..57239329d --- /dev/null +++ b/onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc @@ -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 +#include + +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::getOnlineStatusList()const +{ + return onlineStatusList_; +} + diff --git a/onsmqtt/src/model/QuerySessionByClientIdRequest.cc b/onsmqtt/src/model/QuerySessionByClientIdRequest.cc new file mode 100644 index 000000000..531a0e1fc --- /dev/null +++ b/onsmqtt/src/model/QuerySessionByClientIdRequest.cc @@ -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 + +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); +} + diff --git a/onsmqtt/src/model/QuerySessionByClientIdResult.cc b/onsmqtt/src/model/QuerySessionByClientIdResult.cc new file mode 100644 index 000000000..cda096227 --- /dev/null +++ b/onsmqtt/src/model/QuerySessionByClientIdResult.cc @@ -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 +#include + +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_; +} + diff --git a/onsmqtt/src/model/SendMessageRequest.cc b/onsmqtt/src/model/SendMessageRequest.cc new file mode 100644 index 000000000..eae88cb1a --- /dev/null +++ b/onsmqtt/src/model/SendMessageRequest.cc @@ -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 + +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); +} + diff --git a/onsmqtt/src/model/SendMessageResult.cc b/onsmqtt/src/model/SendMessageResult.cc new file mode 100644 index 000000000..62b7deed8 --- /dev/null +++ b/onsmqtt/src/model/SendMessageResult.cc @@ -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 +#include + +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_; +} +