1
0
Fork 0
Univerxel/src/client/net/Client.hpp

37 lines
824 B
C++
Raw Normal View History

2020-11-03 22:04:43 +00:00
#pragma once
#include "../../core/net/Context.hpp"
#include <functional>
namespace net::client {
enum queue: uint8_t {
GLOBAL = 0,
MOVE,
count
};
2020-11-04 21:04:37 +00:00
/// Network client
2020-11-03 22:04:43 +00:00
class Client final: public Context, public Connection {
public:
Client(const address& ct,
std::function<bool(const data::out_view&, PacketFlags)> onPacket);
~Client();
bool isRunning() const override { return !disconnected; }
/// Read-write on sockets and notify callbacks
void pull() { Context::pull(1000, 50, 20); }
int connectionCallback(uint64_t stream_id, uint8_t *bytes, size_t length,
picoquic_call_back_event_t fin_or_event, void *v_stream_ctx);
private:
bool connected = false;
bool disconnected = false;
std::function<bool(const data::out_view&, PacketFlags)> onPacket;
};
}