mc_protocol v0.0.2 McProtocol.Packet.In

This represents a packet being received from a Server or Client.

This abstraction ensures that a packet is only decoded if it’s actually needed. A proxy could look at the packet type, if it doesn’t need to touch it, it could send on the raw data without even decoding it.

Even if there are several layers calling fetch_packet/1, this also ensures that the packet data is only decoded once. If fetch_packet/1 is never called, the packet is never decoded.

Summary

Functions

Constructs a new In struct, without decoding the packet data. This function would most likely be used in the part of your application that receives the packets from the network

Ensures that the packet is decoded. After this call has succeeded, the packet field of the returned struct is guaranteed to be set

Types

t :: %McProtocol.Packet.In{direction: term, id: term, mode: term, module: term, packet: term, raw: term}

Functions

construct(direction, mode, raw)

Specs

construct(atom, atom, binary) :: t

Constructs a new In struct, without decoding the packet data. This function would most likely be used in the part of your application that receives the packets from the network.

If you use the supplied Acceptor, you should not need to use this.

fetch_packet(holder)

Specs

fetch_packet(%McProtocol.Packet.In{direction: term, id: term, mode: term, module: term, packet: term, raw: term}) :: t

Ensures that the packet is decoded. After this call has succeeded, the packet field of the returned struct is guaranteed to be set.