Documentation
¶
Index ¶
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) CloseWithError(err error)
- func (c *Conn) Conn() io.ReadWriteCloser
- func (c *Conn) Connect() error
- func (c *Conn) ConnectContext(ctx context.Context) error
- func (c *Conn) ConnectTimeout(duration time.Duration) error
- func (c *Conn) Context() context.Context
- func (c *Conn) GameData() minecraft.GameData
- func (c *Conn) ReadPacket() (any, error)
- func (c *Conn) ShieldID() int32
- func (c *Conn) Write(p []byte) error
- func (c *Conn) WritePacket(pk packet.Packet) error
- type Discovery
- type StaticDiscovery
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
}
Conn represents a connection to a server, managing packet reading and writing over an underlying io.ReadWriteCloser.
func NewConn ¶
func NewConn(conn io.ReadWriteCloser, client *minecraft.Conn, logger *slog.Logger, syncProtocol bool, cache []byte) *Conn
NewConn creates a new Conn instance using the provided io.ReadWriteCloser. It is used for reading and writing packets to the underlying connection.
func (*Conn) CloseWithError ¶ added in v0.0.37
CloseWithError closes the underlying connection.
func (*Conn) Conn ¶ added in v0.0.25
func (c *Conn) Conn() io.ReadWriteCloser
Conn returns the underlying connection. Direct access to the underlying connection through this method is strongly discouraged due to the potential for unpredictable behavior. Use this method only when absolutely necessary.
func (*Conn) Connect ¶ added in v0.0.13
Connect initiates the connection sequence with a default timeout of 1 minute.
func (*Conn) ConnectContext ¶ added in v0.0.23
ConnectContext initiates the connection sequence using the provided context for cancellation.
func (*Conn) ConnectTimeout ¶ added in v0.0.23
ConnectTimeout initiates the connection sequence with the specified timeout duration.
func (*Conn) Context ¶ added in v0.0.37
Context returns the connection's context. The context is canceled when the connection is closed, allowing for cancellation of operations that are tied to the lifecycle of the connection.
func (*Conn) GameData ¶
GameData returns the game data set for the connection by the StartGame packet.
func (*Conn) ReadPacket ¶
ReadPacket reads the next available packet from the connection. If there are deferred packets, it will return one of those first. This method should not be called concurrently from multiple goroutines.
func (*Conn) ShieldID ¶ added in v0.0.26
ShieldID returns the shield id set for the connection by the StartGame packet.
type Discovery ¶
type Discovery interface { // Discover determines the primary server. Discover(conn *minecraft.Conn) (string, error) // DiscoverFallback determines the fallback server. DiscoverFallback(conn *minecraft.Conn) (string, error) }
Discovery defines an interface for discovering servers based on a player's connection.
type StaticDiscovery ¶
type StaticDiscovery struct {
// contains filtered or unexported fields
}
StaticDiscovery implements the Discovery interface with static server addresses.
func NewStaticDiscovery ¶
func NewStaticDiscovery(server string, fallbackServer string) *StaticDiscovery
NewStaticDiscovery creates a new StaticDiscovery with the given server addresses.
func (*StaticDiscovery) Discover ¶
func (s *StaticDiscovery) Discover(_ *minecraft.Conn) (string, error)
Discover ...
func (*StaticDiscovery) DiscoverFallback ¶ added in v0.0.23
func (s *StaticDiscovery) DiscoverFallback(_ *minecraft.Conn) (string, error)
DiscoverFallback ...