expresso

package
v0.0.0-...-8eced28 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection is a connection on an Expresso listener.

func (*Connection) Close

func (c *Connection) Close()

Close closes the connection.

func (*Connection) Compression

func (c *Connection) Compression() bool

Compression returns true if the connection is compressing packets.

func (*Connection) CompressionThreshold

func (c *Connection) CompressionThreshold() int32

CompressionThreshold returns the compression threshold for the connection.

func (*Connection) Disconnect

func (c *Connection) Disconnect(reason text.Text)

Disconnect disconnects the connection for a given reason.

func (*Connection) ReadPacket

func (c *Connection) ReadPacket() (packet.Packet, error)

ReadPacket reads a packet from the readable packets available.

func (*Connection) UpdateCompressionThreshold

func (c *Connection) UpdateCompressionThreshold(threshold int32) error

UpdateCompressionThreshold updates the compression threshold for the connection.

func (*Connection) WritePacket

func (c *Connection) WritePacket(pk packet.Packet) error

WritePacket writes a packet to the connection.

type DefaultStatusProvider

type DefaultStatusProvider struct{}

DefaultStatusProvider is the default status of the listener.

func (*DefaultStatusProvider) Status

func (d *DefaultStatusProvider) Status() Status

Status returns the status of the listener.

type ListenConfig

type ListenConfig struct {
	// ErrorLog is a log.Logger that errors that occur during packet handling of clients are written to. By
	// default, ErrorLog is set to one equal to the global logger.
	ErrorLog *log.Logger
	// DisableAuthentication is true if logins should not be verified with Minecraft/Mojang.
	DisableAuthentication bool
	// StatusProvider represents the server list status which is displayed on the multiplayer screen.
	StatusProvider StatusProvider
}

ListenConfig configures certain parts of the listener.

func (ListenConfig) Listen

func (cfg ListenConfig) Listen(address string) (*Listener, error)

Listen listens on the address provided.

type Listener

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

Listener is an Expresso listener. It listens on TCP for Minecraft packets, decodes them, and allows other parts of the program to handle packets.

func Listen

func Listen(address string) (*Listener, error)

Listen listens with a default listener configuration.

func (*Listener) Accept

func (l *Listener) Accept() (*Connection, error)

Accept accepts a new connection from the listener.

func (*Listener) Close

func (l *Listener) Close()

Close closes the listener.

func (*Listener) Status

func (l *Listener) Status() Status

Status returns the server status.

func (*Listener) StatusProvider

func (l *Listener) StatusProvider() StatusProvider

StatusProvider returns the listeners' status provider.

func (*Listener) UpdateStatusProvider

func (l *Listener) UpdateStatusProvider(status StatusProvider)

UpdateStatusProvider updates the server status.

type Player

type Player struct {
	Name string    `json:"name"`
	ID   uuid.UUID `json:"id"`
}

Player represents a player connected to an Expresso listener.

type Players

type Players struct {
	Max    int      `json:"max"`
	Online int      `json:"online"`
	Sample []Player `json:"sample"`
}

Players represents the part of the listener that holds a sample of players.

type Status

type Status struct {
	Version     Version   `json:"version"`
	Players     Players   `json:"players"`
	Description text.Text `json:"description"`
	Favicon     string    `json:"favicon,omitempty"`
}

Status contains status information about the server. It is used for the multiplayer list.

func (Status) String

func (s Status) String() string

String returns the status as a string.

type StatusProvider

type StatusProvider interface {
	// Status returns the status of the listener.
	Status() Status
}

StatusProvider provides the status of the listener when requested.

type Version

type Version struct {
	Name     string `json:"name"`
	Protocol int    `json:"protocol"`
}

Version contains the version and protocol number, used for the status.

Directories

Path Synopsis
Package nbt implements the NBT formats used by Minecraft Bedrock Edition and Minecraft Java Edition.
Package nbt implements the NBT formats used by Minecraft Bedrock Edition and Minecraft Java Edition.

Jump to

Keyboard shortcuts

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