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.
44 lines
827 B
44 lines
827 B
#pragma once |
|
|
|
#include <deque> |
|
#include <exception> |
|
#include <vector> |
|
#include <cstdint> |
|
|
|
namespace devilution { |
|
namespace net { |
|
|
|
typedef std::vector<unsigned char> buffer_t; |
|
|
|
class frame_queue_exception : public std::exception { |
|
public: |
|
const char *what() const throw() override |
|
{ |
|
return "Incorrect frame size"; |
|
} |
|
}; |
|
|
|
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; |
|
buffer_t read(framesize_t s); |
|
|
|
public: |
|
bool packet_ready(); |
|
buffer_t read_packet(); |
|
void write(buffer_t buf); |
|
|
|
static buffer_t make_frame(buffer_t packetbuf); |
|
}; |
|
|
|
} // namespace net |
|
} // namespace devilution
|
|
|