2019-12-27 15:04:18 +00:00
|
|
|
//
|
|
|
|
// Created by loki on 12/27/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SUNSHINE_NETWORK_H
|
|
|
|
#define SUNSHINE_NETWORK_H
|
|
|
|
|
|
|
|
#include <tuple>
|
2020-02-08 15:26:38 +00:00
|
|
|
|
|
|
|
#include <enet/enet.h>
|
|
|
|
|
|
|
|
#include "utility.h"
|
|
|
|
|
2019-12-27 15:04:18 +00:00
|
|
|
namespace net {
|
2020-02-08 15:26:38 +00:00
|
|
|
void free_host(ENetHost *host);
|
|
|
|
|
|
|
|
using host_t = util::safe_ptr<ENetHost, free_host>;
|
|
|
|
using peer_t = ENetPeer*;
|
|
|
|
using packet_t = util::safe_ptr<ENetPacket, enet_packet_destroy>;
|
|
|
|
|
2019-12-27 15:04:18 +00:00
|
|
|
enum net_e : int {
|
|
|
|
PC,
|
|
|
|
LAN,
|
|
|
|
WAN
|
|
|
|
};
|
|
|
|
|
|
|
|
net_e from_enum_string(const std::string_view &view);
|
|
|
|
std::string_view to_enum_string(net_e net);
|
|
|
|
|
|
|
|
net_e from_address(const std::string_view &view);
|
2020-02-08 15:26:38 +00:00
|
|
|
|
|
|
|
host_t host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port);
|
2019-12-27 15:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SUNSHINE_NETWORK_H
|