state

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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
	LastValidProtocol proto.Protocol // defaults to version.MaximumVersion.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)

Register registers a packet type with the corresponding protocol versions for each mapping.

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 {
	State
	ServerBound *PacketRegistry
	ClientBound *PacketRegistry
}

Registry stores server/client bound packets for a specific State.

func NewRegistry

func NewRegistry(state State) *Registry

NewRegistry returns a new state registry.

type State

type State int

State is a Java edition client state.

const (
	HandshakeState State = iota
	StatusState
	LoginState
	PlayState
)

The states the Java edition client connection can be in.

func (State) String

func (s State) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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