33 lines
618 B
C++
33 lines
618 B
C++
#ifndef BROADCASTSERVER_H
|
|
#define BROADCASTSERVER_H
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
|
|
namespace Network {
|
|
|
|
class BroadcastServerImpl;
|
|
|
|
class BroadcastServer
|
|
{
|
|
public:
|
|
BroadcastServer(const std::string& listenAddress, int broadcastPort, std::function<void(const std::string&)> callback);
|
|
~BroadcastServer();
|
|
|
|
public:
|
|
void Receive();
|
|
|
|
std::string Send(const std::string& data, int sourcePort = 0);
|
|
void Broadcast(const std::string& data, int sourcePort = 0);
|
|
|
|
private:
|
|
std::unique_ptr<BroadcastServerImpl> m_pBroadcastServerImpl;
|
|
};
|
|
|
|
} // namespace Network
|
|
|
|
#endif // BROADCASTSERVER_H
|
|
|