mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Remove network connection from local games
This removes need for TCP network connection in single-player games. Instead, game will now create internal pseudo-connection that performs client<->server communication by posting sent messages to client/server asio::io_service'a. This should fix gameplay aborting on switching to another app on iOS (and apparently, on Android in some cases)
This commit is contained in:
@ -57,6 +57,18 @@ void NetworkServer::onDisconnected(const std::shared_ptr<INetworkConnection> & c
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::receiveInternalConnection(std::shared_ptr<IInternalConnection> remoteConnection)
|
||||
{
|
||||
auto localConnection = std::make_shared<InternalConnection>(*this, io);
|
||||
|
||||
connections.insert(localConnection);
|
||||
|
||||
localConnection->connectTo(remoteConnection);
|
||||
remoteConnection->connectTo(localConnection);
|
||||
|
||||
listener.onNewConnection(localConnection);
|
||||
}
|
||||
|
||||
void NetworkServer::onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<std::byte> & message)
|
||||
{
|
||||
listener.onPacketReceived(connection, message);
|
||||
|
Reference in New Issue
Block a user