Initial commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
*.o.*
|
||||||
|
*.d.*
|
||||||
|
*.a.*
|
||||||
|
.*.swp
|
||||||
|
.AppleDouble
|
||||||
|
lib
|
||||||
|
fixPermissions.sh
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../../asio/asio
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef LIBRARIES_ASIO_H
|
||||||
|
#define LIBRARIES_ASIO_H
|
||||||
|
|
||||||
|
#include "asio.hpp"
|
||||||
|
|
||||||
|
#endif // LIBRARIES_ASIO_H
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf
|
||||||
|
#
|
||||||
|
|
||||||
|
CFLAGS += -I$(ROOTPATH) -I$(ROOTPATH)/include -I$(ROOTPATH)/Libraries -I$(ROOTPATH)/Libraries/asio/include -I$(ROOTPATH)/Libraries/Logging/include
|
||||||
|
DEBUGDIR := .debug
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# Makefile.target
|
||||||
|
#
|
||||||
|
|
||||||
|
Network.a.$(ARCH) : $(OBJECTS)
|
||||||
|
$(call build_target_library_arch,$@,$^)
|
||||||
|
|
||||||
|
Network.a:
|
||||||
|
$(call build_target,$@)
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := Network.a
|
||||||
|
|
||||||
|
TARGETS += Network.a
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "BroadcastClientImpl.h"
|
||||||
|
#include "BroadcastClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
BroadcastClient::BroadcastClient(const std::string& listenAddress, int broadcastPort, std::function<void(const std::string&)> callback) :
|
||||||
|
m_pBroadcastClientImpl(new BroadcastClientImpl(listenAddress, broadcastPort, callback))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BroadcastClient::~BroadcastClient() = default;
|
||||||
|
|
||||||
|
void BroadcastClient::Receive()
|
||||||
|
{
|
||||||
|
m_pBroadcastClientImpl->Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string BroadcastClient::Send(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
return m_pBroadcastClientImpl->Send(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BroadcastClient::Broadcast(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
m_pBroadcastClientImpl->Broadcast(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "BroadcastServerImpl.h"
|
||||||
|
#include "BroadcastServer.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
BroadcastServer::BroadcastServer(const std::string& listenAddress, int broadcastPort, std::function<void(const std::string&)> callback) :
|
||||||
|
m_pBroadcastServerImpl(new BroadcastServerImpl(listenAddress, broadcastPort, callback))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BroadcastServer::~BroadcastServer() = default;
|
||||||
|
|
||||||
|
void BroadcastServer::Receive()
|
||||||
|
{
|
||||||
|
m_pBroadcastServerImpl->Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string BroadcastServer::Send(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
return m_pBroadcastServerImpl->Send(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BroadcastServer::Broadcast(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
m_pBroadcastServerImpl->Broadcast(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "IcmpClientImpl.h"
|
||||||
|
#include "IcmpClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
IcmpClient::IcmpClient() :
|
||||||
|
m_pIcmpClientImpl(new IcmpClientImpl())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IcmpClient::~IcmpClient() = default;
|
||||||
|
|
||||||
|
bool IcmpClient::Ping(const std::string& targetAddress)
|
||||||
|
{
|
||||||
|
return m_pIcmpClientImpl->Ping(targetAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../Makefile
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "MulticastClientImpl.h"
|
||||||
|
#include "MulticastClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
MulticastClient::MulticastClient(const std::string& listenAddress, const std::string& multicastAddress, int multicastPort, std::function<void(const std::string&)> callback) :
|
||||||
|
m_pMulticastClientImpl(new MulticastClientImpl(listenAddress, multicastAddress, multicastPort, callback))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MulticastClient::~MulticastClient() = default;
|
||||||
|
|
||||||
|
void MulticastClient::Receive()
|
||||||
|
{
|
||||||
|
m_pMulticastClientImpl->Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MulticastClient::Send(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
return m_pMulticastClientImpl->Send(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MulticastClient::Broadcast(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
m_pMulticastClientImpl->Broadcast(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "UdpClientImpl.h"
|
||||||
|
#include "UdpClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
UdpClient::UdpClient(const std::string& listenAddress, const std::string& targetAddress, int targetPort, std::function<void(const std::string&)> callback) :
|
||||||
|
m_pUdpClientImpl(new UdpClientImpl(listenAddress, targetAddress, targetPort, callback))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UdpClient::~UdpClient() = default;
|
||||||
|
|
||||||
|
void UdpClient::Receive()
|
||||||
|
{
|
||||||
|
m_pUdpClientImpl->Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string UdpClient::Send(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
return m_pUdpClientImpl->Send(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UdpClient::Broadcast(const std::string& data, int sourcePort)
|
||||||
|
{
|
||||||
|
m_pUdpClientImpl->Broadcast(data, sourcePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef BROADCASTCLIENT_H
|
||||||
|
#define BROADCASTCLIENT_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
class BroadcastClientImpl;
|
||||||
|
|
||||||
|
class BroadcastClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BroadcastClient(const std::string& listenAddress, int broadcastPort, std::function<void(const std::string&)> callback);
|
||||||
|
~BroadcastClient();
|
||||||
|
|
||||||
|
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<BroadcastClientImpl> m_pBroadcastClientImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
|
#endif // BROADCASTCLIENT_H
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#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
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef ICMPCLIENT_H
|
||||||
|
#define ICMPCLIENT_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
class IcmpClientImpl;
|
||||||
|
|
||||||
|
class IcmpClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IcmpClient();
|
||||||
|
~IcmpClient();
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool Ping(const std::string& targetAddress);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<IcmpClientImpl> m_pIcmpClientImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
|
#endif // ICMPCLIENT_H
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef MULTICASTCLIENT_H
|
||||||
|
#define MULTICASTCLIENT_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
class MulticastClientImpl;
|
||||||
|
|
||||||
|
class MulticastClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MulticastClient(const std::string& listenAddress, const std::string& multicastAddress, int multicastPort, std::function<void(const std::string&)> callback);
|
||||||
|
~MulticastClient();
|
||||||
|
|
||||||
|
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<MulticastClientImpl> m_pMulticastClientImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
|
#endif // MULTICASTCLIENT_H
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef UDPCLIENT_H
|
||||||
|
#define UDPCLIENT_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
class m_pUdpClientImpl;
|
||||||
|
|
||||||
|
class UdpClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UdpClient(const std::string& listenAddress, const std::string& targetAddress, int targetPort, std::function<void(const std::string&)> callback);
|
||||||
|
~UdpClient();
|
||||||
|
|
||||||
|
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<UdpClientImpl> m_pUdpClientImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
|
#endif // UDPCLIENT_H
|
||||||
|
|
||||||
Reference in New Issue
Block a user