You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
831 B

#pragma once
#include <cstdint>
#include <deque>
#include <exception>
#include <vector>
#include <expected.hpp>
#include "dvlnet/packet.h"
namespace devilution {
namespace net {
typedef std::vector<unsigned char> buffer_t;
typedef uint32_t framesize_t;
class frame_queue {
public:
constexpr static framesize_t max_frame_size = 0xFFFF;
private:
framesize_t current_size = 0;
std::deque<buffer_t> buffer_deque;
framesize_t nextsize = 0;
framesize_t Size() const;
tl::expected<buffer_t, PacketError> Read(framesize_t s);
public:
tl::expected<bool, PacketError> PacketReady();
tl::expected<buffer_t, PacketError> ReadPacket();
void Write(buffer_t buf);
static tl::expected<buffer_t, PacketError> MakeFrame(buffer_t packetbuf);
};
} // namespace net
} // namespace devilution