Support continuous pushing.
This commit is contained in:
@@ -267,6 +267,78 @@ PushClient::CheckDevicesOutcomeCallable PushClient::checkDevicesCallable(const C
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
PushClient::CompleteContinuouslyPushOutcome PushClient::completeContinuouslyPush(const CompleteContinuouslyPushRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return CompleteContinuouslyPushOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return CompleteContinuouslyPushOutcome(CompleteContinuouslyPushResult(outcome.result()));
|
||||
else
|
||||
return CompleteContinuouslyPushOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void PushClient::completeContinuouslyPushAsync(const CompleteContinuouslyPushRequest& request, const CompleteContinuouslyPushAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, completeContinuouslyPush(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
PushClient::CompleteContinuouslyPushOutcomeCallable PushClient::completeContinuouslyPushCallable(const CompleteContinuouslyPushRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<CompleteContinuouslyPushOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->completeContinuouslyPush(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
PushClient::ContinuouslyPushOutcome PushClient::continuouslyPush(const ContinuouslyPushRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ContinuouslyPushOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ContinuouslyPushOutcome(ContinuouslyPushResult(outcome.result()));
|
||||
else
|
||||
return ContinuouslyPushOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void PushClient::continuouslyPushAsync(const ContinuouslyPushRequest& request, const ContinuouslyPushAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, continuouslyPush(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
PushClient::ContinuouslyPushOutcomeCallable PushClient::continuouslyPushCallable(const ContinuouslyPushRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ContinuouslyPushOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->continuouslyPush(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
PushClient::ListPushRecordsOutcome PushClient::listPushRecords(const ListPushRecordsRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
|
||||
60
push/src/model/CompleteContinuouslyPushRequest.cc
Normal file
60
push/src/model/CompleteContinuouslyPushRequest.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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/push/model/CompleteContinuouslyPushRequest.h>
|
||||
|
||||
using AlibabaCloud::Push::Model::CompleteContinuouslyPushRequest;
|
||||
|
||||
CompleteContinuouslyPushRequest::CompleteContinuouslyPushRequest() :
|
||||
RpcServiceRequest("push", "2016-08-01", "CompleteContinuouslyPush")
|
||||
{}
|
||||
|
||||
CompleteContinuouslyPushRequest::~CompleteContinuouslyPushRequest()
|
||||
{}
|
||||
|
||||
std::string CompleteContinuouslyPushRequest::getMessageId()const
|
||||
{
|
||||
return messageId_;
|
||||
}
|
||||
|
||||
void CompleteContinuouslyPushRequest::setMessageId(const std::string& messageId)
|
||||
{
|
||||
messageId_ = messageId;
|
||||
setCoreParameter("MessageId", messageId);
|
||||
}
|
||||
|
||||
std::string CompleteContinuouslyPushRequest::getAccessKeyId()const
|
||||
{
|
||||
return accessKeyId_;
|
||||
}
|
||||
|
||||
void CompleteContinuouslyPushRequest::setAccessKeyId(const std::string& accessKeyId)
|
||||
{
|
||||
accessKeyId_ = accessKeyId;
|
||||
setCoreParameter("AccessKeyId", accessKeyId);
|
||||
}
|
||||
|
||||
long CompleteContinuouslyPushRequest::getAppKey()const
|
||||
{
|
||||
return appKey_;
|
||||
}
|
||||
|
||||
void CompleteContinuouslyPushRequest::setAppKey(long appKey)
|
||||
{
|
||||
appKey_ = appKey;
|
||||
setCoreParameter("AppKey", std::to_string(appKey));
|
||||
}
|
||||
|
||||
51
push/src/model/CompleteContinuouslyPushResult.cc
Normal file
51
push/src/model/CompleteContinuouslyPushResult.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/push/model/CompleteContinuouslyPushResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Push;
|
||||
using namespace AlibabaCloud::Push::Model;
|
||||
|
||||
CompleteContinuouslyPushResult::CompleteContinuouslyPushResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
CompleteContinuouslyPushResult::CompleteContinuouslyPushResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
CompleteContinuouslyPushResult::~CompleteContinuouslyPushResult()
|
||||
{}
|
||||
|
||||
void CompleteContinuouslyPushResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["MessageId"].isNull())
|
||||
messageId_ = value["MessageId"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string CompleteContinuouslyPushResult::getMessageId()const
|
||||
{
|
||||
return messageId_;
|
||||
}
|
||||
|
||||
82
push/src/model/ContinuouslyPushRequest.cc
Normal file
82
push/src/model/ContinuouslyPushRequest.cc
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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/push/model/ContinuouslyPushRequest.h>
|
||||
|
||||
using AlibabaCloud::Push::Model::ContinuouslyPushRequest;
|
||||
|
||||
ContinuouslyPushRequest::ContinuouslyPushRequest() :
|
||||
RpcServiceRequest("push", "2016-08-01", "ContinuouslyPush")
|
||||
{}
|
||||
|
||||
ContinuouslyPushRequest::~ContinuouslyPushRequest()
|
||||
{}
|
||||
|
||||
std::string ContinuouslyPushRequest::getMessageId()const
|
||||
{
|
||||
return messageId_;
|
||||
}
|
||||
|
||||
void ContinuouslyPushRequest::setMessageId(const std::string& messageId)
|
||||
{
|
||||
messageId_ = messageId;
|
||||
setCoreParameter("MessageId", messageId);
|
||||
}
|
||||
|
||||
std::string ContinuouslyPushRequest::getAccessKeyId()const
|
||||
{
|
||||
return accessKeyId_;
|
||||
}
|
||||
|
||||
void ContinuouslyPushRequest::setAccessKeyId(const std::string& accessKeyId)
|
||||
{
|
||||
accessKeyId_ = accessKeyId;
|
||||
setCoreParameter("AccessKeyId", accessKeyId);
|
||||
}
|
||||
|
||||
std::string ContinuouslyPushRequest::getTarget()const
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
void ContinuouslyPushRequest::setTarget(const std::string& target)
|
||||
{
|
||||
target_ = target;
|
||||
setCoreParameter("Target", target);
|
||||
}
|
||||
|
||||
long ContinuouslyPushRequest::getAppKey()const
|
||||
{
|
||||
return appKey_;
|
||||
}
|
||||
|
||||
void ContinuouslyPushRequest::setAppKey(long appKey)
|
||||
{
|
||||
appKey_ = appKey;
|
||||
setCoreParameter("AppKey", std::to_string(appKey));
|
||||
}
|
||||
|
||||
std::string ContinuouslyPushRequest::getTargetValue()const
|
||||
{
|
||||
return targetValue_;
|
||||
}
|
||||
|
||||
void ContinuouslyPushRequest::setTargetValue(const std::string& targetValue)
|
||||
{
|
||||
targetValue_ = targetValue;
|
||||
setCoreParameter("TargetValue", targetValue);
|
||||
}
|
||||
|
||||
51
push/src/model/ContinuouslyPushResult.cc
Normal file
51
push/src/model/ContinuouslyPushResult.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/push/model/ContinuouslyPushResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Push;
|
||||
using namespace AlibabaCloud::Push::Model;
|
||||
|
||||
ContinuouslyPushResult::ContinuouslyPushResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ContinuouslyPushResult::ContinuouslyPushResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ContinuouslyPushResult::~ContinuouslyPushResult()
|
||||
{}
|
||||
|
||||
void ContinuouslyPushResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["MessageId"].isNull())
|
||||
messageId_ = value["MessageId"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string ContinuouslyPushResult::getMessageId()const
|
||||
{
|
||||
return messageId_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user