45 lines
860 B
C++
45 lines
860 B
C++
#pragma once
|
|
|
|
#include "Shared.h"
|
|
#include "Events.h"
|
|
#include "Connection.h"
|
|
|
|
namespace Artifact {
|
|
|
|
namespace Events {
|
|
|
|
struct NetworkMessage {
|
|
void * data;
|
|
};
|
|
|
|
}
|
|
|
|
class NetworkClient;
|
|
|
|
class NetworkServer: public BaseSubsystem, public EventTarget {
|
|
NetworkClient * localClient = nullptr;
|
|
std::unique_ptr<ServerListener> server = nullptr;
|
|
bool active = false;
|
|
uint64_t listener;
|
|
public:
|
|
|
|
void host(NetworkClient * client);
|
|
void host(std::string port);
|
|
|
|
void unhost();
|
|
};
|
|
|
|
class NetworkClient: public BaseSubsystem, public EventTarget {
|
|
NetworkServer * localServer = nullptr;
|
|
std::unique_ptr<Connection> server = nullptr;
|
|
bool active = false;
|
|
uint64_t listener;
|
|
public:
|
|
|
|
void connect(NetworkServer * local);
|
|
void connect(std::string host, std::string port);
|
|
|
|
void disconnect();
|
|
};
|
|
|
|
}
|