session creation fixed
This commit is contained in:
@@ -7,12 +7,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerPixel", "ServerPixel\
|
|||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
build|x64 = build|x64
|
||||||
|
build|x86 = build|x86
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.build|x64.ActiveCfg = Release|x64
|
||||||
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.build|x64.Build.0 = Release|x64
|
||||||
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.build|x86.ActiveCfg = build|Win32
|
||||||
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.build|x86.Build.0 = build|Win32
|
||||||
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x64.ActiveCfg = Debug|x64
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x64.Build.0 = Debug|x64
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x86.ActiveCfg = Debug|Win32
|
{46B65B94-51FC-4B93-9B89-262FD262C49F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
|||||||
+49
-64
@@ -128,30 +128,32 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
// args
|
// args
|
||||||
// 1 - copies amount
|
// 1 - server ip
|
||||||
// 2 - path_to_node.js
|
// 2 - server port
|
||||||
// 3 - start_http_port
|
// 3 - copies amount
|
||||||
// 4 - start_streamer_port
|
// 4 - path_to_node.js
|
||||||
|
// 5 - start_http_port
|
||||||
|
// 6 - start_streamer_port
|
||||||
|
|
||||||
// 5 - path_to_application
|
// 7 - path_to_application
|
||||||
// 6 - application_args (without -pixelStreamingPort cos its argv[3])
|
// 8 - application_args (without -pixelStreamingPort cos its argv[3])
|
||||||
|
|
||||||
// sessions
|
// sessions
|
||||||
uint16_t sessionLimit = std::atoi(argv[1]);
|
uint16_t sessionLimit = std::atoi(argv[3]);
|
||||||
sessionManager sessManager;
|
sessionManager sessManager;
|
||||||
sessManager.setlimit(sessionLimit);
|
sessManager.setlimit(sessionLimit);
|
||||||
|
|
||||||
// merging app arguments
|
// merging app arguments
|
||||||
std::string appPath = argv[5];
|
std::string appPath = argv[7];
|
||||||
std::string appArgs;
|
std::string appArgs;
|
||||||
for (int i = 6; i < argc; ++i)
|
for (int i = 8; i < argc; ++i)
|
||||||
appArgs += argv[i] + std::string(" ");
|
appArgs += argv[i] + std::string(" ");
|
||||||
|
|
||||||
appArgs += "-PixelStreamingPort=";
|
appArgs += "-PixelStreamingPort=";
|
||||||
|
|
||||||
// first app ports
|
// first app ports
|
||||||
uint16_t portHttp = std::atoi(argv[3]);
|
uint16_t portHttp = std::atoi(argv[5]);
|
||||||
uint16_t portStream = std::atoi(argv[4]);
|
uint16_t portStream = std::atoi(argv[6]);
|
||||||
|
|
||||||
// node js
|
// node js
|
||||||
/*std::string nodePath = "C:\\Program Files\\nodejs\\node.exe";
|
/*std::string nodePath = "C:\\Program Files\\nodejs\\node.exe";
|
||||||
@@ -160,14 +162,15 @@ int main(int argc, char* argv[])
|
|||||||
// starting node js servers
|
// starting node js servers
|
||||||
for (uint16_t i = 0; i < sessionLimit; ++i)
|
for (uint16_t i = 0; i < sessionLimit; ++i)
|
||||||
{
|
{
|
||||||
system((std::string("start node ") + argv[2] + " " + std::to_string(portHttp + i) + " " + std::to_string(portStream + i)).c_str());
|
system((std::string("start node ") + argv[4] + " " + std::to_string(portHttp + i) + " " + std::to_string(portStream + i)).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ip and socket init
|
// ip and socket init
|
||||||
std::string ip("192.168.1.115");
|
std::string ip(argv[1]);
|
||||||
uint16_t sess_port = 13002;
|
std::cout << "ip: " << ip << std::endl;
|
||||||
auto const address = net::ip::make_address(ip);
|
auto const address = net::ip::make_address(ip);
|
||||||
auto const port = static_cast<unsigned short>(std::atoi("13001"));
|
auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
|
||||||
|
std::cout << "port: " << port << std::endl;
|
||||||
net::io_context ioc{ 1 };
|
net::io_context ioc{ 1 };
|
||||||
tcp::acceptor acceptor{ ioc, {address, port} };
|
tcp::acceptor acceptor{ ioc, {address, port} };
|
||||||
|
|
||||||
@@ -183,7 +186,6 @@ int main(int argc, char* argv[])
|
|||||||
sock = std::move(socket),
|
sock = std::move(socket),
|
||||||
&sessManager,
|
&sessManager,
|
||||||
&ip,
|
&ip,
|
||||||
&sess_port,
|
|
||||||
&user_n,
|
&user_n,
|
||||||
appPath,
|
appPath,
|
||||||
appArgs,
|
appArgs,
|
||||||
@@ -209,26 +211,16 @@ int main(int argc, char* argv[])
|
|||||||
res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync");
|
res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync");
|
||||||
}));*/
|
}));*/
|
||||||
|
|
||||||
//session sessTmp;
|
|
||||||
session* sessCur = nullptr;
|
|
||||||
uint32_t sessId = 0;
|
|
||||||
uint16_t sessMinPort = sessManager.getMinPort();
|
|
||||||
uint16_t sessHttpPort = sessMinPort ? sessMinPort + 1 : portHttp;
|
|
||||||
uint16_t sessStreamPort = portStream + (sessHttpPort - portHttp);
|
|
||||||
|
|
||||||
//std::cout << "minPort: " << sessMinPort << std::endl;
|
|
||||||
|
|
||||||
//std::cout << "httpPortDefault: " << portHttp << std::endl
|
|
||||||
// << "streamPortDefault: " << portStream << std::endl;
|
|
||||||
|
|
||||||
//std::cout << "httpPort: " << sessHttpPort << std::endl
|
|
||||||
// << "streamPort: " << sessStreamPort << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
nlohmann::json jsonData;
|
nlohmann::json jsonData;
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string content;
|
std::string content;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//session sessTmp;
|
||||||
|
session* sessCur = nullptr;
|
||||||
|
uint32_t sessId = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -292,7 +284,7 @@ int main(int argc, char* argv[])
|
|||||||
ws.write(buffer.data());
|
ws.write(buffer.data());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sessManager.existsOwnerIp(user_ip))
|
if (sessManager.existsOwnerId(user_id))
|
||||||
{
|
{
|
||||||
boost::beast::ostream(buffer)
|
boost::beast::ostream(buffer)
|
||||||
<< std::string("{\"message\" : \"PERSON_LIMIT\"}").c_str();
|
<< std::string("{\"message\" : \"PERSON_LIMIT\"}").c_str();
|
||||||
@@ -300,23 +292,28 @@ int main(int argc, char* argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sessManager
|
|
||||||
|
|
||||||
boost::beast::ostream(buffer)
|
// get session port
|
||||||
<< std::string("{\"message\" : \"CREATING_SESSION\", \"content\" : \"true\"}").c_str();
|
uint16_t sessMinPort = sessManager.getMinPort();
|
||||||
ws.write(buffer.data());
|
uint16_t sessHttpPort = sessMinPort ? sessMinPort + 1 : portHttp;
|
||||||
|
uint16_t sessStreamPort = portStream + (sessHttpPort - portHttp);
|
||||||
|
|
||||||
|
|
||||||
// creating process
|
// creating process
|
||||||
PROCESS_INFORMATION appProcInfo;
|
PROCESS_INFORMATION appProcInfo;
|
||||||
//PROCESS_INFORMATION nodeProcInfo;
|
|
||||||
|
|
||||||
// create app process
|
|
||||||
if (!CreateProc(appPath, appPath + " " + appArgs + std::to_string(sessStreamPort), &appProcInfo))
|
if (!CreateProc(appPath, appPath + " " + appArgs + std::to_string(sessStreamPort), &appProcInfo))
|
||||||
{
|
{
|
||||||
std::cout << "CreateProcess failed (" << GetLastError() << ")." << std::endl;
|
std::cout << "CreateProcess failed (" << GetLastError() << ")." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::beast::ostream(buffer)
|
||||||
|
<< std::string("{\"message\" : \"CREATING_SESSION\", \"content\" : \"true\"}").c_str();
|
||||||
|
ws.write(buffer.data());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// bind app process close listen
|
// bind app process close listen
|
||||||
std::thread([appProcInfo]()
|
std::thread([appProcInfo]()
|
||||||
{
|
{
|
||||||
@@ -325,34 +322,13 @@ int main(int argc, char* argv[])
|
|||||||
CloseHandle(appProcInfo.hThread);
|
CloseHandle(appProcInfo.hThread);
|
||||||
}).detach();
|
}).detach();
|
||||||
|
|
||||||
//std::string nodeArgs = nodePath + " " + nodeFilePath + " "
|
|
||||||
// + std::to_string(sessHttpPort) + " "
|
|
||||||
// + std::to_string(sessStreamPort);
|
|
||||||
|
|
||||||
//// create node js server proc
|
|
||||||
//if (!CreateProc(nodePath, nodePath + " " + nodeFilePath + " "
|
|
||||||
// + std::to_string(sessHttpPort) + " "
|
|
||||||
// + std::to_string(sessStreamPort), &nodeProcInfo))
|
|
||||||
//{
|
|
||||||
// std::cout << "CreateProcess failed (" << GetLastError() << ")." << std::endl;
|
|
||||||
// continue;
|
|
||||||
//}
|
|
||||||
|
|
||||||
////bind node js close listen
|
|
||||||
//std::thread([nodeProcInfo]()
|
|
||||||
// {
|
|
||||||
// WaitForSingleObject(nodeProcInfo.hProcess, INFINITE);
|
|
||||||
// CloseHandle(nodeProcInfo.hProcess);
|
|
||||||
// CloseHandle(nodeProcInfo.hThread);
|
|
||||||
// }).detach();
|
|
||||||
|
|
||||||
sessId = hash6(user_id);
|
sessId = hash6(user_id);
|
||||||
|
|
||||||
// create session
|
// create session
|
||||||
sessManager.add(
|
sessManager.add(
|
||||||
session(
|
session(
|
||||||
sessId,
|
sessId,
|
||||||
ip + std::to_string(sess_port),
|
ip + std::to_string(sessHttpPort),
|
||||||
user_ip,
|
user_ip,
|
||||||
sessHttpPort
|
sessHttpPort
|
||||||
));
|
));
|
||||||
@@ -367,7 +343,8 @@ int main(int argc, char* argv[])
|
|||||||
//sessCur->addProcId(GetProcessId(nodeProcInfo.hProcess));
|
//sessCur->addProcId(GetProcessId(nodeProcInfo.hProcess));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "user(" << thisUserNum << ") created session (id: " << sessId << ")" << std::endl;
|
std::cout << "user(" << thisUserNum << ") created session (id: " << sessId <<
|
||||||
|
"), (httpPort: " << sessHttpPort << "), (streamPort: " << sessStreamPort << ")" << std::endl;
|
||||||
|
|
||||||
// send respond
|
// send respond
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
@@ -378,7 +355,6 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
else if (message == "SESS_CONNECT")
|
else if (message == "SESS_CONNECT")
|
||||||
{
|
{
|
||||||
std::cout << "sess_connect" << std::endl;
|
|
||||||
// read session id
|
// read session id
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -402,10 +378,17 @@ int main(int argc, char* argv[])
|
|||||||
std::cout << "Unknown exception" << e.what() << std::endl;
|
std::cout << "Unknown exception" << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessId = atoi(content.c_str());
|
||||||
// connect to session
|
// connect to session
|
||||||
if (sessManager.getById(atoi(content.c_str()), &sessCur))
|
if (sessManager.getById(sessId, &sessCur))
|
||||||
{
|
{
|
||||||
|
if (sessCur->existsUserId(user_id))
|
||||||
|
{
|
||||||
|
std::cout << "user exists: " << user_id << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sessCur->addUser(user(user_id));
|
sessCur->addUser(user(user_id));
|
||||||
|
|
||||||
std::cout << "user(" << thisUserNum << ") connected to session (id: " << sessCur->getId()
|
std::cout << "user(" << thisUserNum << ") connected to session (id: " << sessCur->getId()
|
||||||
<< "), (users: " << sessCur->getUsersCount() << ")" << std::endl;
|
<< "), (users: " << sessCur->getUsersCount() << ")" << std::endl;
|
||||||
|
|
||||||
@@ -431,6 +414,8 @@ int main(int argc, char* argv[])
|
|||||||
catch (beast::system_error const& se)
|
catch (beast::system_error const& se)
|
||||||
{
|
{
|
||||||
std::cout << "user(" << thisUserNum << ") disconnected" << std::endl;
|
std::cout << "user(" << thisUserNum << ") disconnected" << std::endl;
|
||||||
|
if (!sessManager.getById(sessId, &sessCur))
|
||||||
|
std::cout << "no session with id: " << sessId << std::endl;
|
||||||
if (sessCur)
|
if (sessCur)
|
||||||
{
|
{
|
||||||
sessCur->removeUserById(user_id);
|
sessCur->removeUserById(user_id);
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="build|Win32">
|
||||||
|
<Configuration>build</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="build|x64">
|
||||||
|
<Configuration>build</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
@@ -39,6 +47,13 @@
|
|||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='build|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
@@ -52,6 +67,13 @@
|
|||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='build|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
@@ -63,12 +85,18 @@
|
|||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='build|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='build|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@@ -98,6 +126,22 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='build|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
@@ -112,6 +156,23 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>C:\Libraries\json-develop\include;C:\Libraries\boost\include\boost_1_79_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='build|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
|||||||
@@ -33,11 +33,20 @@ public:
|
|||||||
if (users[i].getId() == id)
|
if (users[i].getId() == id)
|
||||||
users.erase(users.begin() + i);
|
users.erase(users.begin() + i);
|
||||||
}
|
}
|
||||||
|
bool existsUserId(uint32_t id) const
|
||||||
|
{
|
||||||
|
for (auto& u : users)
|
||||||
|
if (u.getId() == id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
inline size_t getUsersCount() const { return users.size(); }
|
inline size_t getUsersCount() const { return users.size(); }
|
||||||
inline const uint32_t& getId() const { return sessId; }
|
inline const uint32_t& getId() const { return sessId; }
|
||||||
|
inline const uint32_t& getOwnerId() const { return sessId; }
|
||||||
inline const std::vector<DWORD>& getProcIds() const { return procIds; }
|
inline const std::vector<DWORD>& getProcIds() const { return procIds; }
|
||||||
inline void addProcId(DWORD procId) { procIds.push_back(procId); }
|
inline void addProcId(DWORD procId) { procIds.push_back(procId); }
|
||||||
inline const std::string& getOwnerIp() const { return ownerIp; }
|
inline const std::string& getOwnerIp() const { return ownerIp; }
|
||||||
inline const uint16_t getPort() const { return port; }
|
inline const uint16_t getPort() const { return port; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,14 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool existsOwnerId(uint32_t id)
|
||||||
|
{
|
||||||
|
for (auto& s : sessions)
|
||||||
|
if (s.getOwnerId() == id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
size_t getCount() { return sessions.size(); }
|
size_t getCount() { return sessions.size(); }
|
||||||
void setlimit(uint32_t limit) { this->limit = limit; }
|
void setlimit(uint32_t limit) { this->limit = limit; }
|
||||||
bool isLimitReached()
|
bool isLimitReached()
|
||||||
|
|||||||
+4
-4
@@ -10,7 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
class user
|
class user
|
||||||
{
|
{
|
||||||
public:
|
private:
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
char age = 0;
|
char age = 0;
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
{
|
{
|
||||||
this->id = id;
|
this->id = id;
|
||||||
}
|
}
|
||||||
std::string getName() { return name; }
|
std::string getName() const { return name; }
|
||||||
char getAge() { return age; }
|
char getAge() const { return age; }
|
||||||
uint32_t getId() { return id; }
|
uint32_t getId() const { return id; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user