Skip to content

Commit

Permalink
some mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanShangin-biterp committed Oct 19, 2022
1 parent b26e0d4 commit 2416f5e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,15 @@ UDP-сокетов и COM-портов, что позволяет с миним
2. Скачать исходники репозитория данного проекта.
3. Запустить файл проекта AddInNative_SynchClientServer.sln в каталоге AddInNative_SynchClientServerWindows.
4. Скачать набор библиотек [Boost](https://www.boost.org/users/download/). Проверенная версия 1.72.0.
5. Собрать файлы .lib библиотек Boost с помощью утилиты b2.exe для платформ win32 и x64. Файлы для разных платформ
5. Запустить bootstrap.bat для сборки утилиты b2.exe.
6. Собрать файлы .lib библиотек Boost с помощью утилиты b2.exe для платформ win32 и x64. Файлы для разных платформ
помещаются в разные папки. Указать пути к каталогам библиотек в свойствах проекта.
```sh
b2.exe -j4 toolset=msvc-14.2 address-model=64 architecture=x86 link=static threading=multi runtime-link=static --build-type=complete --build-dir=build\x64 stage

b2.exe -j4 toolset=msvc-14.2 address-model=32 architecture=x86 link=static threading=multi runtime-link=static --build-type=complete --build-dir=build\x32 stage
```
6. Скачать библиотеку [rapidjson](https://github.com/Tencent/rapidjson/) для работы с JSON. Указать пути к каталогам
7. Скачать библиотеку [rapidjson](https://github.com/Tencent/rapidjson/) для работы с JSON. Указать пути к каталогам
библиотеки в свойствах проекта.

## Сборка компоненты под Linux
Expand Down
27 changes: 13 additions & 14 deletions src/SynchServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ void SynchClientServer::getLastRecordsFromLogHistoryImpl(Biterp::CallContext& ct
prosessLastRecordsFromLogHistory(logHistory, recordsNumber, onlyNew);
}

ctx.setStringResult(u16Converter.from_bytes(logsJsonString));
std::string logsJsonStringLocale = boost::locale::conv::utf_to_utf<char>(logsJsonString.c_str());

ctx.setStringResult(u16Converter.from_bytes(logsJsonStringLocale));
}

bool SynchClientServer::getLoggingRequired()
Expand All @@ -455,8 +457,9 @@ void SynchClientServer::accept_connections_thread(const portSettings_ptr & portS
if (isThreadInterrupted())
break;

synchServer_Wptr weak_ptr_this(shared_from_this());
clientConnection_ptr newConnection_(
new ClientConnection(boost::ref(service_io), portSettings, weak_from_this())
new ClientConnection(boost::ref(service_io), portSettings, weak_ptr_this)
);

boost::system::error_code err;
Expand Down Expand Up @@ -598,20 +601,15 @@ void SynchClientServer::sendMessagesToConnection(const clientConnection_ptr & cl
std::unique_lock<std::mutex> lk(outgoingMessages_mutex);

const std::string & clientSocketUuidString = clientConnection->getClientSocketUuidString();
bool sendWithDelay = false;
for (auto const& message_ptr : outgoingMessages) {
const std::string & m_clientSocketUuidString = message_ptr->getClientSocketUuidStringRef();
bool isMessageForThisConnection = clientSocketUuidString == m_clientSocketUuidString;

if (isMessageForThisConnection
&& !message_ptr->isMessageProcessingCompleted()) {
message_ptr->takeMesssageInProsessing();
clientConnection->sendMessage(message_ptr, sendWithDelay);
clientConnection->sendMessage(message_ptr);
message_ptr->completeProsessingMesssage();

// delay only for the second and following messages
if (sendWithDelay)
sendWithDelay = true;
}
}
}
Expand Down Expand Up @@ -654,15 +652,16 @@ const clientConnection_ptr SynchClientServer::getCreateClientConnectionToRemoteS
return std::shared_ptr<ClientConnection>(nullptr);
}

clientConnection_ptr åxistingÑonnection = getExistingClientConnectionToRemoteServer(portSettings);
if (åxistingÑonnection) {
return åxistingÑonnection;
clientConnection_ptr existingConnection = getExistingClientConnectionToRemoteServer(portSettings);
if (existingConnection) {
return existingConnection;
}

// can not find existing connection. Create new one and try to establish connection

synchServer_Wptr weak_ptr_this(shared_from_this());
clientConnection_ptr newConnection_(
new ClientConnection(boost::ref(service_io), portSettings, weak_from_this())
new ClientConnection(boost::ref(service_io), portSettings, weak_ptr_this)
);

bool successfully = newConnection_->reconnectSocketRemoteServer();
Expand Down Expand Up @@ -787,9 +786,9 @@ bool ClientConnection::readDataFromSocket()
return haveNewData;
}

void ClientConnection::sendMessage(const message_ptr &message, bool withDelay)
void ClientConnection::sendMessage(const message_ptr &message)
{
if (withDelay)
if (delayMessageSending_ > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(delayMessageSending_));

if (synchServer_Sptr server_shp = server_.lock()) {
Expand Down
2 changes: 1 addition & 1 deletion src/SynchServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class ClientConnection {

void acceptConnection();
bool readDataFromSocket();
void sendMessage(const message_ptr &message, bool withDelay);
void sendMessage(const message_ptr &message);
bool isTimedOut();
void closeSocket();
bool reconnectSocketRemoteServer();
Expand Down
24 changes: 12 additions & 12 deletions windows/WindowsAddin/WindowsAddin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>E:\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);E:\dev\rapidjson-master\include;$(WindowsSDK_IncludePath)</IncludePath>
<LibraryPath>C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<LibraryPath>E:\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>E:\dev\rapidjson-master\include;$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
<LibraryPath>C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>E:\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>E:\dev\rapidjson-master\include;$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
<LibraryPath>C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(ProjectDir)..\..\lib\win_$(Platform)\cfg_$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>C:\Users\REShangin\Documents\dev\rapidjson-master\include;$(ProjectDir)..\..\src\;$(ProjectDir)..\..\src\windows\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -123,7 +123,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>E:\dev\boost_1_72_0</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
Expand All @@ -134,7 +134,7 @@
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>AddinNative.def</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>E:\dev\boost_1_72_0\stage\x86</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0\stage\x86</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -146,7 +146,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<AdditionalIncludeDirectories>E:\dev\boost_1_72_0</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -155,7 +155,7 @@
<ModuleDefinitionFile>AddinNative.def</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<Profile>true</Profile>
<AdditionalLibraryDirectories>E:\dev\boost_1_72_0\stage\x64</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0\stage\x64</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -169,7 +169,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>E:\dev\boost_1_72_0</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<Optimization>Disabled</Optimization>
</ClCompile>
Expand All @@ -181,7 +181,7 @@
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>AddinNative.def</ModuleDefinitionFile>
<AdditionalDependencies>Crypt32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>E:\dev\boost_1_72_0\stage\x64</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0\stage\x64</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 2416f5e

Please sign in to comment.