network

package
v0.0.0-...-05212bf Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(log zerolog.Logger, underlying net.Conn) *Conn

func (*Conn) Close

func (c *Conn) Close() error

Close closes this connection. This method is idempotent.

func (Conn) IP

func (c Conn) IP() net.IP

IP returns the IP address of the remote end of this connection.

func (Conn) Phase

func (c Conn) Phase() packet.Phase

Phase returns the packet.Phase that this connection is currently in.

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() (packet.Serverbound, error)

ReadPacket will attempt to read and decode a serverbound packet from this connection. This method will block until either the connection is closed, in which case this method will return an error, or until a serverbound packet is received. If the packet is malformed or contains invalid values, then a respective error that is describing the issue is returned. A packet is considered as containing invalid values if the packet definition implements the packet.Validator interface and the validation fails.

func (*Conn) TransitionTo

func (c *Conn) TransitionTo(phase packet.Phase)

TransitionTo sets the phase of this connection to the given phase. This method will panic if the transition is invalid.

func (*Conn) WritePacket

func (c *Conn) WritePacket(p packet.Clientbound) error

WritePacket writes the given clientbound packet to the client, returning any error if any returns.

type Error

type Error string
const (
	// ErrClosed indicates, that the component is already
	// closed, and required resources might already have
	// been released.
	ErrClosed Error = "already closed"
)

func (Error) Error

func (e Error) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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