1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Initial version of antilag support

This commit is contained in:
Ivan Savenko
2025-06-28 21:42:54 +03:00
parent 58de180083
commit 3576efc3f3
24 changed files with 490 additions and 23 deletions

View File

@@ -22,11 +22,19 @@ std::unique_ptr<INetworkHandler> INetworkHandler::createHandler()
NetworkHandler::NetworkHandler()
: io(std::make_unique<NetworkContext>())
, strand(std::make_unique<NetworkStrand>(*io))
{}
std::unique_ptr<INetworkServer> NetworkHandler::createServerTCP(INetworkServerListener & listener)
{
return std::make_unique<NetworkServer>(listener, *io);
return std::make_unique<NetworkServer>(listener, *io, *strand);
}
std::shared_ptr<INetworkConnection> NetworkHandler::createAsyncConnection(INetworkConnectionListener & listener)
{
auto loopbackConnection = std::make_shared<InternalConnection>(listener, *strand);
loopbackConnection->connectTo(loopbackConnection);
return loopbackConnection;
}
void NetworkHandler::connectToRemote(INetworkClientListener & listener, const std::string & host, uint16_t port)
@@ -75,7 +83,7 @@ void NetworkHandler::createTimer(INetworkTimerListener & listener, std::chrono::
void NetworkHandler::createInternalConnection(INetworkClientListener & listener, INetworkServer & server)
{
auto localConnection = std::make_shared<InternalConnection>(listener, *io);
auto localConnection = std::make_shared<InternalConnection>(listener, *strand);
server.receiveInternalConnection(localConnection);