Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
IPacket Class Referenceabstract

Interface for all Packets. More...

#include <packet.h>

Inheritance diagram for IPacket:
DisconnectLogin DisconnectPlay EncryptionRequest EncryptionResponse HandshakePacket LoginStart LoginSuccess PingPongPacket ServerListPacket SetCompression

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.
 

Detailed Description

Interface for all Packets.

The sole interface that all packets should inherit. Includes only the basics such as the id and the basic functions.

Constructor & Destructor Documentation

◆ IPacket()

IPacket::IPacket ( int id)
inlineprotected

Construct a new IPacket object.

Everything is pretty much said.

Parameters
idthe Packet id, refer to IPacket::id

Member Function Documentation

◆ read()

virtual void IPacket::read ( IMCStream * stream)
pure virtual

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()

Parameters
streamthe stream to read from

Implemented in HandshakePacket, EncryptionRequest, EncryptionResponse, LoginStart, LoginSuccess, SetCompression, DisconnectPlay, DisconnectLogin, PingPongPacket, and ServerListPacket.

◆ send()

void IPacket::send ( IMCStream * stream)

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.

Parameters
stream

◆ write()

virtual void IPacket::write ( IMCStream * stream)
protectedpure virtual

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.

Parameters
streamthe stream to write to

Implemented in HandshakePacket, PingPongPacket, and ServerListPacket.

Member Data Documentation

◆ id

int IPacket::id

Packet Id.

The id of the packet for Minecraft, should be copied from https://wiki.vg (see 1.8.9)


The documentation for this class was generated from the following files: