Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Connection ¶
type Connection interface { ReadPacket() (packet.Packet, error) WritePacket(packet.Packet) error SetReadDeadline(time.Time) error SetWriteDeadline(time.Time) error Close() error SetState(state game.ConnectionState) }
Connection represents a connection to a Minecraft server or client.
func Dial ¶
func Dial(address string, opts ...Option) (Connection, string, error)
Dial connects to the specified address and creates a new Connection for it. Returns the connection & the address that was connected to.
See DialContext for more information.
func DialContext ¶
DialContext creates a TCP connection with specified address and creates a new Connection for it. If no port is specified, the Minecraft default of 25565 will be used.
Just like the vanilla Minecraft client, DialContext will do an SRV DNS lookup before connecting to a Minecraft server with the default port. If an SRV record is found, the contained target and port will be used to connect instead.
The provided Context must be non-nil. If the context expires before the connection is established, an error is returned. Once successfully connected, any expiration of this context will not affect the connection.
The given options will be applied to the created connection.
Will return the created Connection and the resolved address that was connected to.
func Wrap ¶
func Wrap(conn net.Conn, opts ...Option) Connection
Wrap wraps the given connection with a Connection, so it can be used for sending/receiving Minecraft packets.
Wrap defaults its side to ServerSide, which means it will interpret incoming packets as being server-bound. If you are using Wrap for the client side, use the WithSide option to configure this. Wrap will also default the connection state to packet.HandshakeState. If you are wrapping a connection which is in a different state, use the WithState option to configure this.
The given options will be applied to the created connection.
type Logger ¶
type Logger interface { Debug(v ...interface{}) Debugf(format string, v ...interface{}) }
type Option ¶
type Option func(conn *connection)
Option is a configuration option for mcproto.
func WithLogger ¶
WithLogger configures the logger for mcproto.
func WithPackets ¶
WithPackets allows you to add custom packets to mcproto's packet registry. This will make mcproto automatically parse the packet when it is received.
func WithState ¶
func WithState(state game.ConnectionState) Option
type Side ¶
type Side uint8
Side is the side of a Minecraft connection
func (Side) ReadDirection ¶
func (Side) WriteDirection ¶
type UnknownPacketError ¶
type UnknownPacketError struct {
// contains filtered or unexported fields
}
func (UnknownPacketError) Error ¶
func (u UnknownPacketError) Error() string