Skip to content

Commit 0975d6d

Browse files
author
jeffgaogao
committed
feat(TcrSdk): 上传demo
1 parent 6c60cd8 commit 0975d6d

File tree

214 files changed

+37717
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+37717
-32
lines changed

.gitignore

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1 @@
1-
# Prerequisites
2-
*.d
3-
4-
# Compiled Object files
5-
*.slo
6-
*.lo
7-
*.o
8-
*.obj
9-
10-
# Precompiled Headers
11-
*.gch
12-
*.pch
13-
14-
# Compiled Dynamic libraries
15-
*.so
16-
*.dylib
17-
*.dll
18-
19-
# Fortran module files
20-
*.mod
21-
*.smod
22-
23-
# Compiled Static libraries
24-
*.lai
25-
*.la
26-
*.a
27-
*.lib
28-
29-
# Executables
30-
*.exe
31-
*.out
32-
*.app
1+
.vs/

TcrDemo/TcrDemo.vcxproj

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<ItemGroup>
22+
<ClCompile Include="cloud_game_api.cpp" />
23+
<ClCompile Include="crash_dump.cpp" />
24+
<ClCompile Include="http_client.cpp" />
25+
<ClCompile Include="main.cc" />
26+
<ClCompile Include="main_wnd.cc" />
27+
<ClCompile Include="my_tcr_logger.cpp" />
28+
<ClCompile Include="video_renderer.cpp" />
29+
</ItemGroup>
30+
<ItemGroup>
31+
<ClInclude Include="cloud_game_api.h" />
32+
<ClInclude Include="crash_dump.h" />
33+
<ClInclude Include="http_client.h" />
34+
<ClInclude Include="main_wnd.h" />
35+
<ClInclude Include="my_tcr_logger.h" />
36+
<ClInclude Include="video_renderer.h" />
37+
</ItemGroup>
38+
<PropertyGroup Label="Globals">
39+
<VCProjectVersion>16.0</VCProjectVersion>
40+
<Keyword>Win32Proj</Keyword>
41+
<ProjectGuid>{dd2ab69c-95d3-4241-ba31-9786f59fd23c}</ProjectGuid>
42+
<RootNamespace>TcrDemo</RootNamespace>
43+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
44+
</PropertyGroup>
45+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
47+
<ConfigurationType>Application</ConfigurationType>
48+
<UseDebugLibraries>true</UseDebugLibraries>
49+
<PlatformToolset>v142</PlatformToolset>
50+
<CharacterSet>Unicode</CharacterSet>
51+
</PropertyGroup>
52+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
53+
<ConfigurationType>Application</ConfigurationType>
54+
<UseDebugLibraries>false</UseDebugLibraries>
55+
<PlatformToolset>v142</PlatformToolset>
56+
<WholeProgramOptimization>true</WholeProgramOptimization>
57+
<CharacterSet>Unicode</CharacterSet>
58+
</PropertyGroup>
59+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
60+
<ConfigurationType>Application</ConfigurationType>
61+
<UseDebugLibraries>true</UseDebugLibraries>
62+
<PlatformToolset>v142</PlatformToolset>
63+
<CharacterSet>Unicode</CharacterSet>
64+
</PropertyGroup>
65+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
66+
<ConfigurationType>Application</ConfigurationType>
67+
<UseDebugLibraries>false</UseDebugLibraries>
68+
<PlatformToolset>v142</PlatformToolset>
69+
<WholeProgramOptimization>true</WholeProgramOptimization>
70+
<CharacterSet>Unicode</CharacterSet>
71+
</PropertyGroup>
72+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
73+
<ImportGroup Label="ExtensionSettings">
74+
</ImportGroup>
75+
<ImportGroup Label="Shared">
76+
</ImportGroup>
77+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
79+
</ImportGroup>
80+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
81+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
82+
</ImportGroup>
83+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
84+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
85+
</ImportGroup>
86+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
87+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
88+
</ImportGroup>
89+
<PropertyGroup Label="UserMacros" />
90+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
91+
<LinkIncremental>true</LinkIncremental>
92+
</PropertyGroup>
93+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
94+
<LinkIncremental>false</LinkIncremental>
95+
</PropertyGroup>
96+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
97+
<LinkIncremental>true</LinkIncremental>
98+
</PropertyGroup>
99+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
100+
<LinkIncremental>false</LinkIncremental>
101+
</PropertyGroup>
102+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
103+
<ClCompile>
104+
<WarningLevel>Level3</WarningLevel>
105+
<SDLCheck>true</SDLCheck>
106+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
107+
<ConformanceMode>true</ConformanceMode>
108+
</ClCompile>
109+
<Link>
110+
<SubSystem>Windows</SubSystem>
111+
<GenerateDebugInformation>true</GenerateDebugInformation>
112+
</Link>
113+
</ItemDefinitionGroup>
114+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
115+
<ClCompile>
116+
<WarningLevel>Level3</WarningLevel>
117+
<FunctionLevelLinking>true</FunctionLevelLinking>
118+
<IntrinsicFunctions>true</IntrinsicFunctions>
119+
<SDLCheck>true</SDLCheck>
120+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121+
<ConformanceMode>true</ConformanceMode>
122+
</ClCompile>
123+
<Link>
124+
<SubSystem>Windows</SubSystem>
125+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
126+
<OptimizeReferences>true</OptimizeReferences>
127+
<GenerateDebugInformation>true</GenerateDebugInformation>
128+
</Link>
129+
</ItemDefinitionGroup>
130+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
131+
<ClCompile>
132+
<WarningLevel>Level3</WarningLevel>
133+
<SDLCheck>true</SDLCheck>
134+
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
135+
<ConformanceMode>true</ConformanceMode>
136+
</ClCompile>
137+
<Link>
138+
<SubSystem>Windows</SubSystem>
139+
<GenerateDebugInformation>true</GenerateDebugInformation>
140+
</Link>
141+
</ItemDefinitionGroup>
142+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
143+
<ClCompile>
144+
<WarningLevel>Level3</WarningLevel>
145+
<FunctionLevelLinking>true</FunctionLevelLinking>
146+
<IntrinsicFunctions>true</IntrinsicFunctions>
147+
<SDLCheck>true</SDLCheck>
148+
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
149+
<ConformanceMode>true</ConformanceMode>
150+
<AdditionalIncludeDirectories>$(ProjectDir)tcrsdk\include;$(ProjectDir)spdlog-1.12.0\include;$(ProjectDir)jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
151+
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
152+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
153+
</ClCompile>
154+
<Link>
155+
<SubSystem>Windows</SubSystem>
156+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
157+
<OptimizeReferences>true</OptimizeReferences>
158+
<GenerateDebugInformation>true</GenerateDebugInformation>
159+
<AdditionalLibraryDirectories>$(ProjectDir)tcrsdk\libs\x64;$(ProjectDir)jsoncpp\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
160+
<AdditionalDependencies>TcrSdk-Win.lib;json_reader.obj;json_value.obj;json_writer.obj;wininet.lib;winmm.lib;winspool.lib;winhttp.lib;%(AdditionalDependencies)</AdditionalDependencies>
161+
</Link>
162+
<PreBuildEvent>
163+
<Command>xcopy /E /Y "$(ProjectDir)tcrsdk\libs\x64" "$(OutDir)"</Command>
164+
</PreBuildEvent>
165+
</ItemDefinitionGroup>
166+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
167+
<ImportGroup Label="ExtensionTargets">
168+
</ImportGroup>
169+
</Project>

TcrDemo/TcrDemo.vcxproj.filters

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="源文件">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="头文件">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="资源文件">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="cloud_game_api.cpp">
19+
<Filter>源文件</Filter>
20+
</ClCompile>
21+
<ClCompile Include="crash_dump.cpp">
22+
<Filter>源文件</Filter>
23+
</ClCompile>
24+
<ClCompile Include="http_client.cpp">
25+
<Filter>源文件</Filter>
26+
</ClCompile>
27+
<ClCompile Include="main.cc">
28+
<Filter>源文件</Filter>
29+
</ClCompile>
30+
<ClCompile Include="main_wnd.cc">
31+
<Filter>源文件</Filter>
32+
</ClCompile>
33+
<ClCompile Include="my_tcr_logger.cpp">
34+
<Filter>源文件</Filter>
35+
</ClCompile>
36+
<ClCompile Include="video_renderer.cpp">
37+
<Filter>源文件</Filter>
38+
</ClCompile>
39+
</ItemGroup>
40+
<ItemGroup>
41+
<ClInclude Include="cloud_game_api.h">
42+
<Filter>头文件</Filter>
43+
</ClInclude>
44+
<ClInclude Include="crash_dump.h">
45+
<Filter>头文件</Filter>
46+
</ClInclude>
47+
<ClInclude Include="http_client.h">
48+
<Filter>头文件</Filter>
49+
</ClInclude>
50+
<ClInclude Include="main_wnd.h">
51+
<Filter>头文件</Filter>
52+
</ClInclude>
53+
<ClInclude Include="my_tcr_logger.h">
54+
<Filter>头文件</Filter>
55+
</ClInclude>
56+
<ClInclude Include="video_renderer.h">
57+
<Filter>头文件</Filter>
58+
</ClInclude>
59+
</ItemGroup>
60+
</Project>

TcrDemo/TcrDemo.vcxproj.user

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

TcrDemo/cloud_game_api.cpp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#include "cloud_game_api.h"
2+
3+
#include<string>
4+
#include <random>
5+
#include <sstream>
6+
#include <iostream>
7+
#include <thread>
8+
9+
#include "json/json.h"
10+
11+
using namespace std;
12+
namespace uuid {
13+
static std::random_device rd;
14+
static std::mt19937 gen(rd());
15+
static std::uniform_int_distribution<> dis(0, 15);
16+
static std::uniform_int_distribution<> dis2(8, 11);
17+
18+
std::string generate_uuid_v4() {
19+
std::stringstream ss;
20+
int i;
21+
ss << std::hex;
22+
for (i = 0; i < 8; i++) {
23+
ss << dis(gen);
24+
}
25+
ss << "-";
26+
for (i = 0; i < 4; i++) {
27+
ss << dis(gen);
28+
}
29+
ss << "-4";
30+
for (i = 0; i < 3; i++) {
31+
ss << dis(gen);
32+
}
33+
ss << "-";
34+
ss << dis2(gen);
35+
for (i = 0; i < 3; i++) {
36+
ss << dis(gen);
37+
}
38+
ss << "-";
39+
for (i = 0; i < 12; i++) {
40+
ss << dis(gen);
41+
};
42+
return ss.str();
43+
}
44+
}
45+
46+
CloudGameApi::CloudGameApi()
47+
{
48+
http_client_.reset(new HttpClient(L"User-Agent"));
49+
}
50+
51+
CloudGameApi::~CloudGameApi() {
52+
53+
}
54+
55+
void CloudGameApi::startGame(std::string params, ServerResponseListener* listener)
56+
{
57+
std::thread t([listener, params, this]() {
58+
std::vector<std::wstring> headers;
59+
headers.push_back(L"Content-Type: application/json; charset=utf-8\\");
60+
61+
std::string respData;
62+
std::wstring url = to_wstring("https://code.cloud-gaming.myqcloud.com/CreateExperienceSession");
63+
DWORD ret = http_client_->http_post(url, headers, params, respData);
64+
if (0 != ret || true == respData.empty())
65+
{
66+
//请求失败,请检查参数或网络。
67+
listener->onFailed("Connect to server failed.");
68+
}
69+
else {
70+
listener->onSuccess(respData);
71+
}
72+
});
73+
t.detach();
74+
}
75+
76+
void CloudGameApi::stopGame(std::string& param, ServerResponseListener* listener)
77+
{
78+
}
79+
80+
std::string CloudGameApi::createGameStartParam(const std::string& clientSession, const std::string &experienceCode)
81+
{
82+
Json::Value root;
83+
root["RequestId"] = uuid::generate_uuid_v4();
84+
root["ExperienceCode"] = experienceCode;
85+
root["UserId"] = uuid::generate_uuid_v4();
86+
root["ClientSession"] = clientSession;
87+
return Json::FastWriter().write(root);
88+
}
89+
90+
std::wstring CloudGameApi::to_wstring(std::string input) {
91+
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
92+
return converter.from_bytes(input);
93+
}

0 commit comments

Comments
 (0)