1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/lib/network/NetworkServer.h

39 lines
1.2 KiB
C++
Raw Normal View History

/*
* NetworkServer.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "NetworkDefines.h"
VCMI_LIB_NAMESPACE_BEGIN
2024-01-12 01:10:41 +02:00
class NetworkServer : public INetworkConnectionListener, public INetworkServer
{
2024-01-12 01:10:41 +02:00
std::shared_ptr<NetworkContext> io;
std::shared_ptr<NetworkAcceptor> acceptor;
2024-01-12 01:10:41 +02:00
std::set<std::shared_ptr<INetworkConnection>> connections;
INetworkServerListener & listener;
void connectionAccepted(std::shared_ptr<NetworkSocket>, const boost::system::error_code & ec);
void startAsyncAccept();
2023-11-12 13:27:22 +02:00
2024-01-12 01:10:41 +02:00
void onDisconnected(const std::shared_ptr<INetworkConnection> & connection) override;
void onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<uint8_t> & message) override;
public:
2024-01-12 01:10:41 +02:00
NetworkServer(INetworkServerListener & listener, const std::shared_ptr<NetworkContext> & context);
2024-01-12 01:10:41 +02:00
void sendPacket(const std::shared_ptr<INetworkConnection> &, const std::vector<uint8_t> & message) override;
void closeConnection(const std::shared_ptr<INetworkConnection> &) override;
2024-01-12 01:10:41 +02:00
void start(uint16_t port) override;
};
VCMI_LIB_NAMESPACE_END