state

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Handshake = NewRegistry(HandshakeState)
	Status    = NewRegistry(StatusState)
	Login     = NewRegistry(LoginState)
	Play      = NewRegistry(PlayState)
)

The registries storing the packets for a connection state.

Functions

This section is empty.

Types

type PacketMapping

type PacketMapping struct {
	Id       proto.PacketId
	Protocol proto.Protocol
}

type PacketRegistry

type PacketRegistry struct {
	Direction proto.Direction                      // The direction the registered packets are send to.
	Protocols map[proto.Protocol]*ProtocolRegistry // The protocol versions.
	// Whether to fallback to the minimum protocol version
	// in case a protocol could not be found.
	Fallback bool
}

PacketRegistry stores packets protocol versions sent to server or client.

func NewPacketRegistry

func NewPacketRegistry(direction proto.Direction) *PacketRegistry

func (*PacketRegistry) ProtocolRegistry

func (p *PacketRegistry) ProtocolRegistry(protocol proto.Protocol) *ProtocolRegistry

ProtocolRegistry gets the ProtocolRegistry for a protocol.

func (*PacketRegistry) Register

func (p *PacketRegistry) Register(packetOf proto.Packet, mappings ...*PacketMapping)

type ProtocolRegistry

type ProtocolRegistry struct {
	Protocol    proto.Protocol                      // The protocol version of the registered packets.
	PacketIds   map[proto.PacketId]proto.PacketType // Gets packet type by packet id.
	PacketTypes map[proto.PacketType]proto.PacketId // Gets packet id by packet type.
}

ProtocolRegistry stores packets of a protocol version.

func FromDirection

func FromDirection(direction proto.Direction, state *Registry, protocol proto.Protocol) *ProtocolRegistry

func (*ProtocolRegistry) CreatePacket

func (r *ProtocolRegistry) CreatePacket(id proto.PacketId) proto.Packet

CreatePacket returns a new zero valued instance of the type of the mapped packet id or nil if not found.

func (*ProtocolRegistry) PacketId

func (r *ProtocolRegistry) PacketId(of proto.Packet) (id proto.PacketId, found bool)

PacketId gets the packet id by the registered packet type.

type Registry

type Registry struct {
	proto.State
	ServerBound *PacketRegistry
	ClientBound *PacketRegistry
}

Registry stores server/client bound packets.

func NewRegistry

func NewRegistry(state proto.State) *Registry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL