12#ifndef MINESERVER_STREAM_H
13#define MINESERVER_STREAM_H
46 virtual void read(std::byte *buffer, std::size_t offset, std::size_t len) = 0;
57 virtual void write(
const std::byte *buffer, std::size_t offset, std::size_t len) = 0;
294 std::vector<std::byte> data;
295 std::uint32_t readIndex{};
316 void read(std::byte *buffer, std::size_t offset, std::size_t len)
override;
325 void write(
const std::byte *buffer, std::size_t offset, std::size_t len)
override;
331 void flush()
override;
359 const std::vector<std::byte> &
getData()
const;
394 void read(std::byte *buffer, std::size_t offset, std::size_t len)
override;
403 void write(
const std::byte *buffer, std::size_t offset, std::size_t len)
override;
423 void flush()
override;
461 void read(std::byte *buffer, std::size_t offset, std::size_t len)
override;
469 void write(
const std::byte *buffer, std::size_t offset, std::size_t len)
override;
493 void flush()
override;
509 std::vector<std::byte> inBuffer{};
510 std::uint32_t inIndex{};
512 std::vector<std::byte> outBuffer{};
537 void read(std::byte *buffer, std::size_t offset, std::size_t len)
override;
545 void write(
const std::byte *buffer, std::size_t offset, std::size_t len)
override;
573 void flush()
override;
The file containing minecraft chat message implementation.
Minecraft Chat Message implementation.
Definition chatmessage.h:28
AES 128bit CFB8 Cipher stream.
Definition stream.h:433
CipherStream(IMCStream *baseStream, std::byte *key, std::byte *iv)
Construct a new Cipher Stream object.
Definition stream.cpp:439
size_t available() override
Gets the number of available bytes Returns the number of available bytes in the sub-stream....
Definition stream.cpp:473
void write(const std::byte *buffer, std::size_t offset, std::size_t len) override
Writes to an encrypted stream.
Definition stream.cpp:464
void finishPacketWrite(const std::byte *packetData, size_t len) override
Finishes to write the packet in a Minecrafty way.
Definition stream.cpp:478
~CipherStream()
Destroy the Cipher Stream object.
Definition stream.cpp:446
void read(std::byte *buffer, std::size_t offset, std::size_t len) override
Reads from an encrypted stream.
Definition stream.cpp:451
void flush() override
Flushes the base stream.
Definition stream.cpp:484
Network POSIX Client.
Definition network.h:42
Stream interface.
Definition stream.h:32
void writeUUID(const MinecraftUUID &uuid)
Writes an MinecraftUUID.
Definition stream.cpp:348
void writeByte(std::int8_t b)
Writes a Byte.
Definition stream.cpp:39
std::int32_t readVarInt()
Reads a Variable Integer.
Definition stream.cpp:269
void writeUnsignedByte(std::uint8_t b)
Writes an Unsigned Byte.
Definition stream.cpp:50
void writeVarLong(std::int64_t l)
Writes a Variable Long.
Definition stream.cpp:332
std::int64_t readVarLong()
Reads a Variable Long.
Definition stream.cpp:309
std::int64_t readLong()
Reads a Long.
Definition stream.cpp:145
float readFloat()
Reads a Float.
Definition stream.cpp:185
virtual size_t available()=0
Gets the number of available bytes.
void writeFloat(float f)
Writes a Float.
Definition stream.cpp:191
void writeChat(const ChatMessage &c)
Writes a Chat Message.
Definition stream.cpp:240
ChatMessage readChat()
Reads a Chat Message.
Definition stream.cpp:224
void writeUnsignedShort(std::uint16_t s)
Writes an Unsigned short.
Definition stream.cpp:98
void writeDouble(double d)
Writes a Double.
Definition stream.cpp:203
void writeLong(std::int64_t l)
Writes a Long.
Definition stream.cpp:167
virtual void finishPacketWrite(const std::byte *packetData, size_t len)=0
Finishes packet write to stream.
std::uint16_t readUnsignedShort()
Reads an Unsigned Short.
Definition stream.cpp:92
std::string readString()
Reads a String.
Definition stream.cpp:208
double readDouble()
Reads a Double.
Definition stream.cpp:196
void writeShort(std::int16_t s)
Writes a Short.
Definition stream.cpp:72
void writeBoolean(bool b)
Writes a Boolean.
Definition stream.cpp:27
void writeInt(std::int32_t i)
Writes a Integer.
Definition stream.cpp:126
void writeVarInt(std::int32_t i)
Writes a Variable Integer.
Definition stream.cpp:293
virtual void write(const std::byte *buffer, std::size_t offset, std::size_t len)=0
Writes data to the sub-class.
MinecraftUUID readUUID()
Reads an MinecraftUUID.
Definition stream.cpp:355
void writeString(const std::string &s)
Writes a String.
Definition stream.cpp:218
virtual void flush()=0
Flushes the stream.
std::int32_t readInt()
Reads an Integer.
Definition stream.cpp:103
std::int8_t readByte()
Reads a Byte.
Definition stream.cpp:32
std::uint8_t readUnsignedByte()
Reads an Unsigned Byte.
Definition stream.cpp:44
std::int16_t readShort()
Reads a Short.
Definition stream.cpp:55
bool readBoolean()
Reads a Boolean.
Definition stream.cpp:20
virtual void read(std::byte *buffer, std::size_t offset, std::size_t len)=0
Reads data from the sub-class.
A stream from Memory.
Definition stream.h:292
void write(const std::byte *buffer, std::size_t offset, std::size_t len) override
Writes to the stream.
Definition stream.cpp:372
const std::vector< std::byte > & getData() const
Get the written data.
Definition stream.cpp:399
void clear()
Cleares the stream.
Definition stream.cpp:393
size_t available() override
Gets the number of available bytes.
Definition stream.cpp:382
void flush() override
Flushes the stream.
Definition stream.cpp:377
MemoryStream()=default
Construct a new Memory Stream object.
void read(std::byte *buffer, std::size_t offset, std::size_t len) override
Reads from the stream.
Definition stream.cpp:366
~MemoryStream() override=default
Destroy the Memory Stream object.
void finishPacketWrite(const std::byte *packetData, size_t len) override
Finishes to write the packet in a Minecrafty way.
Definition stream.cpp:387
MinecraftUUID compliant data holder.
Definition uuid.h:27
Stream from a net client socket.
Definition stream.h:368
void write(const std::byte *buffer, std::size_t offset, std::size_t len) override
Writes to the network socket.
Definition stream.cpp:418
size_t available() override
Gets the number of available bytes.
Definition stream.cpp:423
void read(std::byte *buffer, std::size_t offset, std::size_t len) override
Reads from the network socket.
Definition stream.cpp:413
void finishPacketWrite(const std::byte *packetData, size_t len) override
Finishes to write the packet in a Minecrafty way.
Definition stream.cpp:428
void flush() override
Flushes the stream.
Definition stream.cpp:434
NetSocketStream(const ClientSocket &socket)
Construct a new Net Socket Stream object.
Definition stream.cpp:404
~NetSocketStream()
Destroy the Net Socket Stream object.
Definition stream.cpp:408
ZLib Stream.
Definition stream.h:504
void write(const std::byte *buffer, std::size_t offset, std::size_t len) override
Writes to a compressed stream.
Definition stream.cpp:504
void finishPacketWrite(const std::byte *packetData, size_t len) override
Finishes to write the packet in a Minecrafty way.
Definition stream.cpp:529
ZLibStream(IMCStream *baseStream, int level, int threshold)
Construct a new ZLibStream object.
Definition stream.cpp:489
size_t available() override
Gets the number of available bytes.
Definition stream.cpp:509
void flush() override
Flushes the stream.
Definition stream.cpp:548
void read(std::byte *buffer, std::size_t offset, std::size_t len) override
Reads from a compressed stream.
Definition stream.cpp:498
~ZLibStream()
Destroy the ZLibStream object.
Definition stream.cpp:493
AES/CFB8 128bit cipher class.
Definition crypto.h:205
ZLib compressor.
Definition crypto.h:271
The file containing all the logic for encryption.
The network (TCP) cross-platform implementation.
The file containing MinecraftUUID logic.