26 lines
788 B
C++
26 lines
788 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <map>
|
|
#include <netdb.h>
|
|
|
|
#include "RemotePeer.hpp"
|
|
|
|
|
|
/**
|
|
* Information about the current state of our machine.
|
|
* Used everywhere to determinate how to behave.
|
|
*/
|
|
class Context {
|
|
public:
|
|
int socket = -1; /// current socket file descriptor, used to communicate
|
|
addrinfo* broadcastAddressInfo = nullptr; /// address used to broadcast messages
|
|
std::shared_ptr<RemotePeer> server = nullptr; /// peer currently used as the server
|
|
|
|
Peer me; /// information about our own machine
|
|
std::map<
|
|
std::uint32_t,
|
|
std::shared_ptr<RemotePeer>
|
|
> remotePeers {}; /// information about other machines
|
|
std::chrono::high_resolution_clock::time_point latestPeerDiscovery; /// time of the latest discovered machine
|
|
};
|