Add Support For Create Chat Session.
This commit is contained in:
86
lingmou/CMakeLists.txt
Normal file
86
lingmou/CMakeLists.txt
Normal file
@@ -0,0 +1,86 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||
|
||||
set(lingmou_public_header
|
||||
include/alibabacloud/lingmou/LingMouClient.h
|
||||
include/alibabacloud/lingmou/LingMouExport.h )
|
||||
|
||||
set(lingmou_public_header_model
|
||||
include/alibabacloud/lingmou/model/CreateChatSessionRequest.h
|
||||
include/alibabacloud/lingmou/model/CreateChatSessionResult.h )
|
||||
|
||||
set(lingmou_src
|
||||
src/LingMouClient.cc
|
||||
src/model/CreateChatSessionRequest.cc
|
||||
src/model/CreateChatSessionResult.cc )
|
||||
|
||||
add_library(lingmou ${LIB_TYPE}
|
||||
${lingmou_public_header}
|
||||
${lingmou_public_header_model}
|
||||
${lingmou_src})
|
||||
|
||||
set_target_properties(lingmou
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}lingmou
|
||||
)
|
||||
|
||||
if(${LIB_TYPE} STREQUAL "SHARED")
|
||||
set_target_properties(lingmou
|
||||
PROPERTIES
|
||||
DEFINE_SYMBOL ALIBABACLOUD_LINGMOU_LIBRARY)
|
||||
endif()
|
||||
|
||||
target_include_directories(lingmou
|
||||
PRIVATE include
|
||||
${CMAKE_SOURCE_DIR}/core/include
|
||||
)
|
||||
target_link_libraries(lingmou
|
||||
core)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
|
||||
set(jsoncpp_install_dir ${INSTALL_DIR})
|
||||
add_dependencies(lingmou
|
||||
jsoncpp)
|
||||
target_include_directories(lingmou
|
||||
PRIVATE ${jsoncpp_install_dir}/include)
|
||||
target_link_libraries(lingmou
|
||||
${jsoncpp_install_dir}/lib/jsoncpp.lib)
|
||||
set_target_properties(lingmou
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS "/bigobj")
|
||||
else()
|
||||
target_include_directories(lingmou
|
||||
PRIVATE /usr/include/jsoncpp)
|
||||
target_link_libraries(lingmou
|
||||
jsoncpp)
|
||||
endif()
|
||||
|
||||
install(FILES ${lingmou_public_header}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/lingmou)
|
||||
install(FILES ${lingmou_public_header_model}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/lingmou/model)
|
||||
install(TARGETS lingmou
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
54
lingmou/include/alibabacloud/lingmou/LingMouClient.h
Normal file
54
lingmou/include/alibabacloud/lingmou/LingMouClient.h
Normal 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_LINGMOU_LINGMOUCLIENT_H_
|
||||
#define ALIBABACLOUD_LINGMOU_LINGMOUCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/EndpointProvider.h>
|
||||
#include <alibabacloud/core/RoaServiceClient.h>
|
||||
#include "LingMouExport.h"
|
||||
#include "model/CreateChatSessionRequest.h"
|
||||
#include "model/CreateChatSessionResult.h"
|
||||
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace LingMou
|
||||
{
|
||||
class ALIBABACLOUD_LINGMOU_EXPORT LingMouClient : public RoaServiceClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, Model::CreateChatSessionResult> CreateChatSessionOutcome;
|
||||
typedef std::future<CreateChatSessionOutcome> CreateChatSessionOutcomeCallable;
|
||||
typedef std::function<void(const LingMouClient*, const Model::CreateChatSessionRequest&, const CreateChatSessionOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateChatSessionAsyncHandler;
|
||||
|
||||
LingMouClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
LingMouClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
LingMouClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
~LingMouClient();
|
||||
CreateChatSessionOutcome createChatSession(const Model::CreateChatSessionRequest &request)const;
|
||||
void createChatSessionAsync(const Model::CreateChatSessionRequest& request, const CreateChatSessionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
CreateChatSessionOutcomeCallable createChatSessionCallable(const Model::CreateChatSessionRequest& request) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_LINGMOU_LINGMOUCLIENT_H_
|
||||
32
lingmou/include/alibabacloud/lingmou/LingMouExport.h
Normal file
32
lingmou/include/alibabacloud/lingmou/LingMouExport.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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_LINGMOU_LINGMOUEXPORT_H_
|
||||
#define ALIBABACLOUD_LINGMOU_LINGMOUEXPORT_H_
|
||||
|
||||
#include <alibabacloud/core/Global.h>
|
||||
|
||||
#if defined(ALIBABACLOUD_SHARED)
|
||||
# if defined(ALIBABACLOUD_LINGMOU_LIBRARY)
|
||||
# define ALIBABACLOUD_LINGMOU_EXPORT ALIBABACLOUD_DECL_EXPORT
|
||||
# else
|
||||
# define ALIBABACLOUD_LINGMOU_EXPORT ALIBABACLOUD_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define ALIBABACLOUD_LINGMOU_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_LINGMOU_LINGMOUEXPORT_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_LINGMOU_MODEL_CREATECHATSESSIONREQUEST_H_
|
||||
#define ALIBABACLOUD_LINGMOU_MODEL_CREATECHATSESSIONREQUEST_H_
|
||||
|
||||
#include <alibabacloud/lingmou/LingMouExport.h>
|
||||
#include <alibabacloud/core/RoaServiceRequest.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace AlibabaCloud {
|
||||
namespace LingMou {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_LINGMOU_EXPORT CreateChatSessionRequest : public RoaServiceRequest {
|
||||
public:
|
||||
CreateChatSessionRequest();
|
||||
~CreateChatSessionRequest();
|
||||
std::string getLicense() const;
|
||||
void setLicense(const std::string &license);
|
||||
std::string getInstanceId() const;
|
||||
void setInstanceId(const std::string &instanceId);
|
||||
std::string getId() const;
|
||||
void setId(const std::string &id);
|
||||
std::string getPlatform() const;
|
||||
void setPlatform(const std::string &platform);
|
||||
|
||||
private:
|
||||
std::string license_;
|
||||
std::string instanceId_;
|
||||
std::string id_;
|
||||
std::string platform_;
|
||||
};
|
||||
} // namespace Model
|
||||
} // namespace LingMou
|
||||
} // namespace AlibabaCloud
|
||||
#endif // !ALIBABACLOUD_LINGMOU_MODEL_CREATECHATSESSIONREQUEST_H_
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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_LINGMOU_MODEL_CREATECHATSESSIONRESULT_H_
|
||||
#define ALIBABACLOUD_LINGMOU_MODEL_CREATECHATSESSIONRESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/lingmou/LingMouExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace LingMou
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_LINGMOU_EXPORT CreateChatSessionResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
struct RtcParams
|
||||
{
|
||||
std::string gslb;
|
||||
std::string nonce;
|
||||
std::string appId;
|
||||
std::string serverUserId;
|
||||
std::string channel;
|
||||
std::string token;
|
||||
std::string avatarUserId;
|
||||
std::string clientUserId;
|
||||
long timestamp;
|
||||
};
|
||||
struct AvatarAssets
|
||||
{
|
||||
std::string secret;
|
||||
std::string type;
|
||||
std::string minRequiredVersion;
|
||||
std::string url;
|
||||
std::string md5;
|
||||
};
|
||||
AvatarAssets avatarAssets;
|
||||
RtcParams rtcParams;
|
||||
std::string sessionId;
|
||||
};
|
||||
|
||||
|
||||
CreateChatSessionResult();
|
||||
explicit CreateChatSessionResult(const std::string &payload);
|
||||
~CreateChatSessionResult();
|
||||
std::string getRequestId()const;
|
||||
std::string getMessage()const;
|
||||
long getHttpStatusCode()const;
|
||||
Data getData()const;
|
||||
std::string getCode()const;
|
||||
bool getSuccess()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string requestId_;
|
||||
std::string message_;
|
||||
long httpStatusCode_;
|
||||
Data data_;
|
||||
std::string code_;
|
||||
bool success_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_LINGMOU_MODEL_CREATECHATSESSIONRESULT_H_
|
||||
89
lingmou/src/LingMouClient.cc
Normal file
89
lingmou/src/LingMouClient.cc
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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/lingmou/LingMouClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::LingMou;
|
||||
using namespace AlibabaCloud::LingMou::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string SERVICE_NAME = "LingMou";
|
||||
}
|
||||
|
||||
LingMouClient::LingMouClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
RoaServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
|
||||
}
|
||||
|
||||
LingMouClient::LingMouClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
RoaServiceClient(SERVICE_NAME, credentialsProvider, configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
|
||||
}
|
||||
|
||||
LingMouClient::LingMouClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
|
||||
RoaServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
|
||||
}
|
||||
|
||||
LingMouClient::~LingMouClient()
|
||||
{}
|
||||
|
||||
LingMouClient::CreateChatSessionOutcome LingMouClient::createChatSession(const CreateChatSessionRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return CreateChatSessionOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return CreateChatSessionOutcome(CreateChatSessionResult(outcome.result()));
|
||||
else
|
||||
return CreateChatSessionOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void LingMouClient::createChatSessionAsync(const CreateChatSessionRequest& request, const CreateChatSessionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, createChatSession(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
LingMouClient::CreateChatSessionOutcomeCallable LingMouClient::createChatSessionCallable(const CreateChatSessionRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<CreateChatSessionOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->createChatSession(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
64
lingmou/src/model/CreateChatSessionRequest.cc
Normal file
64
lingmou/src/model/CreateChatSessionRequest.cc
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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/lingmou/model/CreateChatSessionRequest.h>
|
||||
|
||||
using AlibabaCloud::LingMou::Model::CreateChatSessionRequest;
|
||||
|
||||
CreateChatSessionRequest::CreateChatSessionRequest()
|
||||
: RoaServiceRequest("lingmou", "2025-05-27") {
|
||||
setResourcePath("/openapi/chat/init/[id]"};
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
CreateChatSessionRequest::~CreateChatSessionRequest() {}
|
||||
|
||||
std::string CreateChatSessionRequest::getLicense() const {
|
||||
return license_;
|
||||
}
|
||||
|
||||
void CreateChatSessionRequest::setLicense(const std::string &license) {
|
||||
license_ = license;
|
||||
setParameter(std::string("license"), license);
|
||||
}
|
||||
|
||||
std::string CreateChatSessionRequest::getInstanceId() const {
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
void CreateChatSessionRequest::setInstanceId(const std::string &instanceId) {
|
||||
instanceId_ = instanceId;
|
||||
setParameter(std::string("instanceId"), instanceId);
|
||||
}
|
||||
|
||||
std::string CreateChatSessionRequest::getId() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
void CreateChatSessionRequest::setId(const std::string &id) {
|
||||
id_ = id;
|
||||
setParameter(std::string("id"), id);
|
||||
}
|
||||
|
||||
std::string CreateChatSessionRequest::getPlatform() const {
|
||||
return platform_;
|
||||
}
|
||||
|
||||
void CreateChatSessionRequest::setPlatform(const std::string &platform) {
|
||||
platform_ = platform;
|
||||
setParameter(std::string("platform"), platform);
|
||||
}
|
||||
|
||||
117
lingmou/src/model/CreateChatSessionResult.cc
Normal file
117
lingmou/src/model/CreateChatSessionResult.cc
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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/lingmou/model/CreateChatSessionResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::LingMou;
|
||||
using namespace AlibabaCloud::LingMou::Model;
|
||||
|
||||
CreateChatSessionResult::CreateChatSessionResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
CreateChatSessionResult::CreateChatSessionResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
CreateChatSessionResult::~CreateChatSessionResult()
|
||||
{}
|
||||
|
||||
void CreateChatSessionResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["data"];
|
||||
if(!dataNode["sessionId"].isNull())
|
||||
data_.sessionId = dataNode["sessionId"].asString();
|
||||
auto rtcParamsNode = dataNode["rtcParams"];
|
||||
if(!rtcParamsNode["appId"].isNull())
|
||||
data_.rtcParams.appId = rtcParamsNode["appId"].asString();
|
||||
if(!rtcParamsNode["avatarUserId"].isNull())
|
||||
data_.rtcParams.avatarUserId = rtcParamsNode["avatarUserId"].asString();
|
||||
if(!rtcParamsNode["channel"].isNull())
|
||||
data_.rtcParams.channel = rtcParamsNode["channel"].asString();
|
||||
if(!rtcParamsNode["clientUserId"].isNull())
|
||||
data_.rtcParams.clientUserId = rtcParamsNode["clientUserId"].asString();
|
||||
if(!rtcParamsNode["gslb"].isNull())
|
||||
data_.rtcParams.gslb = rtcParamsNode["gslb"].asString();
|
||||
if(!rtcParamsNode["nonce"].isNull())
|
||||
data_.rtcParams.nonce = rtcParamsNode["nonce"].asString();
|
||||
if(!rtcParamsNode["serverUserId"].isNull())
|
||||
data_.rtcParams.serverUserId = rtcParamsNode["serverUserId"].asString();
|
||||
if(!rtcParamsNode["timestamp"].isNull())
|
||||
data_.rtcParams.timestamp = std::stol(rtcParamsNode["timestamp"].asString());
|
||||
if(!rtcParamsNode["token"].isNull())
|
||||
data_.rtcParams.token = rtcParamsNode["token"].asString();
|
||||
auto avatarAssetsNode = dataNode["avatarAssets"];
|
||||
if(!avatarAssetsNode["url"].isNull())
|
||||
data_.avatarAssets.url = avatarAssetsNode["url"].asString();
|
||||
if(!avatarAssetsNode["md5"].isNull())
|
||||
data_.avatarAssets.md5 = avatarAssetsNode["md5"].asString();
|
||||
if(!avatarAssetsNode["secret"].isNull())
|
||||
data_.avatarAssets.secret = avatarAssetsNode["secret"].asString();
|
||||
if(!avatarAssetsNode["type"].isNull())
|
||||
data_.avatarAssets.type = avatarAssetsNode["type"].asString();
|
||||
if(!avatarAssetsNode["minRequiredVersion"].isNull())
|
||||
data_.avatarAssets.minRequiredVersion = avatarAssetsNode["minRequiredVersion"].asString();
|
||||
if(!value["requestId"].isNull())
|
||||
requestId_ = value["requestId"].asString();
|
||||
if(!value["message"].isNull())
|
||||
message_ = value["message"].asString();
|
||||
if(!value["httpStatusCode"].isNull())
|
||||
httpStatusCode_ = std::stol(value["httpStatusCode"].asString());
|
||||
if(!value["code"].isNull())
|
||||
code_ = value["code"].asString();
|
||||
if(!value["success"].isNull())
|
||||
success_ = value["success"].asString() == "true";
|
||||
|
||||
}
|
||||
|
||||
std::string CreateChatSessionResult::getRequestId()const
|
||||
{
|
||||
return requestId_;
|
||||
}
|
||||
|
||||
std::string CreateChatSessionResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
long CreateChatSessionResult::getHttpStatusCode()const
|
||||
{
|
||||
return httpStatusCode_;
|
||||
}
|
||||
|
||||
CreateChatSessionResult::Data CreateChatSessionResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
std::string CreateChatSessionResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
bool CreateChatSessionResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user