Support session query operations.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
53
onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc
Normal file
53
onsmqtt/src/model/BatchQuerySessionByClientIdsRequest.cc
Normal 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);
|
||||
}
|
||||
|
||||
59
onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc
Normal file
59
onsmqtt/src/model/BatchQuerySessionByClientIdsResult.cc
Normal 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_;
|
||||
}
|
||||
|
||||
51
onsmqtt/src/model/QuerySessionByClientIdRequest.cc
Normal file
51
onsmqtt/src/model/QuerySessionByClientIdRequest.cc
Normal 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);
|
||||
}
|
||||
|
||||
51
onsmqtt/src/model/QuerySessionByClientIdResult.cc
Normal file
51
onsmqtt/src/model/QuerySessionByClientIdResult.cc
Normal 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_;
|
||||
}
|
||||
|
||||
62
onsmqtt/src/model/SendMessageRequest.cc
Normal file
62
onsmqtt/src/model/SendMessageRequest.cc
Normal 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);
|
||||
}
|
||||
|
||||
51
onsmqtt/src/model/SendMessageResult.cc
Normal file
51
onsmqtt/src/model/SendMessageResult.cc
Normal 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_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user