1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Simplified networking API

This commit is contained in:
Ivan Savenko
2024-01-12 16:55:36 +02:00
parent 9fb7d2817a
commit 709905b1a0
12 changed files with 62 additions and 142 deletions

View File

@@ -30,7 +30,6 @@ public:
virtual bool isConnected() const = 0;
virtual void sendPacket(const std::vector<uint8_t> & message) = 0;
virtual void start(const std::string & host, uint16_t port) = 0;
};
/// Base class for incoming connections support
@@ -91,9 +90,13 @@ public:
virtual std::unique_ptr<INetworkServer> createServerTCP(INetworkServerListener & listener) = 0;
/// Creates an instance of TCP client that allows to establish single outgoing connection to a remote port
virtual std::unique_ptr<INetworkClient> createClientTCP(INetworkClientListener & listener) = 0;
/// On success: INetworkTimerListener::onConnectionEstablished() will be called, established connection provided as parameter
/// On failure: INetworkTimerListener::onConnectionFailed will be called with human-readable error message
virtual void connectToRemote(INetworkClientListener & listener, const std::string & host, uint16_t port) = 0;
/// Creates a timer that will be called once, after specified interval has passed
/// On success: INetworkTimerListener::onTimer() will be called
/// On failure: no-op
virtual void createTimer(INetworkTimerListener & listener, std::chrono::milliseconds duration) = 0;
/// Starts network processing on this thread. Does not returns until networking processing has been terminated