Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
Interface for all Packets. More...
#include <packet.h>
Public Member Functions | |
virtual | ~IPacket ()=default |
Destroy the IPacket object. | |
virtual void | read (IMCStream *stream)=0 |
Reads data from the stream to a packet. | |
void | send (IMCStream *stream) |
Sends a Packet in Minecraft format. | |
Public Attributes | |
int | id |
Packet Id. | |
Protected Member Functions | |
virtual void | write (IMCStream *stream)=0 |
Write packet data to stream. | |
IPacket (int id) | |
Construct a new IPacket object. | |
Interface for all Packets.
The sole interface that all packets should inherit. Includes only the basics such as the id and the basic functions.
|
inlineprotected |
Construct a new IPacket object.
Everything is pretty much said.
id | the Packet id, refer to IPacket::id |
Reads data from the stream to a packet.
Reads corresponding data from the stream, interpreting it to the packet format. Should be overriden when creating a new subsequent class and can be used anywhere on any stream, unlike IPackert::write()
stream | the stream to read from |
Implemented in HandshakePacket, EncryptionRequest, EncryptionResponse, LoginStart, LoginSuccess, SetCompression, DisconnectPlay, DisconnectLogin, PingPongPacket, and ServerListPacket.
Sends a Packet in Minecraft format.
Writes the packet data as well as id and length, following minecraft's implementation of packeting. Refer to https://wiki.vg for more information as to their structure.
stream |
Write packet data to stream.
Writes raw packet data to a stream, excluding id and length. If you want to send a packet to a stream you should use IPacket::send() instead Ideally only used internally and overriden by children classes.
stream | the stream to write to |
Implemented in HandshakePacket, PingPongPacket, and ServerListPacket.
int IPacket::id |
Packet Id.
The id of the packet for Minecraft, should be copied from https://wiki.vg (see 1.8.9)