Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
Stream interface. More...
#include <stream.h>
Public Member Functions | |
virtual void | read (std::byte *buffer, std::size_t offset, std::size_t len)=0 |
Reads data from the sub-class. | |
virtual void | write (const std::byte *buffer, std::size_t offset, std::size_t len)=0 |
Writes data to the sub-class. | |
virtual void | flush ()=0 |
Flushes the stream. | |
virtual size_t | available ()=0 |
Gets the number of available bytes. | |
virtual void | finishPacketWrite (const std::byte *packetData, size_t len)=0 |
Finishes packet write to stream. | |
bool | readBoolean () |
Reads a Boolean. | |
void | writeBoolean (bool b) |
Writes a Boolean. | |
std::int8_t | readByte () |
Reads a Byte. | |
void | writeByte (std::int8_t b) |
Writes a Byte. | |
std::uint8_t | readUnsignedByte () |
Reads an Unsigned Byte. | |
void | writeUnsignedByte (std::uint8_t b) |
Writes an Unsigned Byte. | |
std::int16_t | readShort () |
Reads a Short. | |
void | writeShort (std::int16_t s) |
Writes a Short. | |
std::uint16_t | readUnsignedShort () |
Reads an Unsigned Short. | |
void | writeUnsignedShort (std::uint16_t s) |
Writes an Unsigned short. | |
std::int32_t | readInt () |
Reads an Integer. | |
void | writeInt (std::int32_t i) |
Writes a Integer. | |
std::int64_t | readLong () |
Reads a Long. | |
void | writeLong (std::int64_t l) |
Writes a Long. | |
float | readFloat () |
Reads a Float. | |
void | writeFloat (float f) |
Writes a Float. | |
double | readDouble () |
Reads a Double. | |
void | writeDouble (double d) |
Writes a Double. | |
std::string | readString () |
Reads a String. | |
void | writeString (const std::string &s) |
Writes a String. | |
ChatMessage | readChat () |
Reads a Chat Message. | |
void | writeChat (const ChatMessage &c) |
Writes a Chat Message. | |
std::int32_t | readVarInt () |
Reads a Variable Integer. | |
void | writeVarInt (std::int32_t i) |
Writes a Variable Integer. | |
std::int64_t | readVarLong () |
Reads a Variable Long. | |
void | writeVarLong (std::int64_t l) |
Writes a Variable Long. | |
MinecraftUUID | readUUID () |
Reads an MinecraftUUID. | |
void | writeUUID (const MinecraftUUID &uuid) |
Writes an MinecraftUUID. | |
Stream interface.
The interface that all the streams should implement, and it has the necessary functions for IO using the Minecraft protocol.
Gets the number of available bytes.
Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.
Finishes packet write to stream.
packetData | the packet data (id + data) |
len | the length of the data |
Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.
Flushes the stream.
Empties the buffer, sending it correctly, resets any offset / data.
Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.
|
pure virtual |
Reads data from the sub-class.
Standard-compliant way of reading from a stream. Will write len
bytes of data at maximum to the buffer
starting at offset
buffer | the buffer to write to |
offset | the offset to start writing at |
len | the maximum length to write |
Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.
bool IMCStream::readBoolean | ( | ) |
Reads a Boolean.
Reads a boolean from the stream in a Minecrafty way.
std::int8_t IMCStream::readByte | ( | ) |
Reads a Byte.
Reads a byte from the stream in a Minecrafty way.
ChatMessage IMCStream::readChat | ( | ) |
Reads a Chat Message.
Reads a chat message from the stream in a Minecrafty way.
double IMCStream::readDouble | ( | ) |
Reads a Double.
Reads a double from the stream in a Minecrafty way.
float IMCStream::readFloat | ( | ) |
Reads a Float.
Reads a float from the stream in a Minecrafty way.
std::int32_t IMCStream::readInt | ( | ) |
Reads an Integer.
Reads an integer from the stream in a Minecrafty way.
std::int64_t IMCStream::readLong | ( | ) |
Reads a Long.
Reads a long from the stream in a Minecrafty way.
std::int16_t IMCStream::readShort | ( | ) |
Reads a Short.
Reads a short from the stream in a Minecrafty way.
std::string IMCStream::readString | ( | ) |
Reads a String.
Reads a string from the stream in a Minecrafty way.
std::uint8_t IMCStream::readUnsignedByte | ( | ) |
Reads an Unsigned Byte.
Reads an unsigned byte from the stream in a Minecrafty way.
std::uint16_t IMCStream::readUnsignedShort | ( | ) |
Reads an Unsigned Short.
Reads an unsigned short from the stream in a Minecrafty way.
MinecraftUUID IMCStream::readUUID | ( | ) |
Reads an MinecraftUUID.
Reads 16 bytes from the stream and interprets them as an MinecraftUUID.
std::int32_t IMCStream::readVarInt | ( | ) |
Reads a Variable Integer.
Reads a variable integer from the stream in a Minecrafty way, following google's standard on Variable Integers.
std::int64_t IMCStream::readVarLong | ( | ) |
Reads a Variable Long.
Reads a variable long from the stream in a Minecrafty way, following google's standard on Variable Longs.
|
pure virtual |
Writes data to the sub-class.
Standard-compliant way of writing to a stream. Will read a maximum of len
bytes from buffer
starting at offset
buffer | the buffer to read from |
offset | the offset to start reading from |
len | the maximum read length |
Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.
Writes a Boolean.
Writes a boolean to the stream in a Minecraft way.
b | the boolean to write |
void IMCStream::writeByte | ( | std::int8_t | b | ) |
Writes a Byte.
Writes a byte to the stream in a Minecraft way.
b | the byte to write |
void IMCStream::writeChat | ( | const ChatMessage & | c | ) |
Writes a Chat Message.
Writes a chat message to the stream in a Minecraft way.
c | the chat message to write |
Writes a Double.
Writes a double to the stream in a Minecraft way.
d | the double to write |
Writes a Float.
Writes a float to the stream in a Minecraft way.
f | the float to write |
void IMCStream::writeInt | ( | std::int32_t | i | ) |
Writes a Integer.
Writes an integer to the stream in a Minecraft way.
i | the integer to write |
void IMCStream::writeLong | ( | std::int64_t | l | ) |
Writes a Long.
Writes a long to the stream in a Minecraft way.
l | the long to write |
void IMCStream::writeShort | ( | std::int16_t | s | ) |
Writes a Short.
Writes a short to the stream in a Minecraft way.
s | the short to write |
Writes a String.
Writes a string to the stream in a Minecraft way.
s | the string to write |
void IMCStream::writeUnsignedByte | ( | std::uint8_t | b | ) |
Writes an Unsigned Byte.
Writes an unsigned byte to the stream in a Minecraft way.
b | the unsigned byte to write |
void IMCStream::writeUnsignedShort | ( | std::uint16_t | s | ) |
Writes an Unsigned short.
Writes a unsigned short to the stream in a Minecraft way.
s | the unsigned short to write |
void IMCStream::writeUUID | ( | const MinecraftUUID & | uuid | ) |
Writes an MinecraftUUID.
Writes an MinecraftUUID to the stream.
uuid | the MinecraftUUID to write |
void IMCStream::writeVarInt | ( | std::int32_t | i | ) |
Writes a Variable Integer.
Writes a variable integer to the stream in a Minecraft way, following google's standard on Variable Integers.
i | the variable integer to write |
void IMCStream::writeVarLong | ( | std::int64_t | l | ) |
Writes a Variable Long.
Writes a variable long to the stream in a Minecraft way, following google's standard on Variable Longs.
l | the variable long to write |