Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BufferPool = sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 256)) }, }
BufferPool is a sync.Pool for buffers used to write compressed data to.
var CompressPool = sync.Pool{ New: func() interface{} { w, _ := flate.NewWriter(ioutil.Discard, 6) return w }, }
CompressPool is a sync.Pool for writeCloseResetter flate readers. These are pooled for connections.
var DecompressPool = sync.Pool{ New: func() interface{} { return flate.NewReader(bytes.NewReader(nil)) }, }
DecompressPool is a sync.Pool for io.ReadCloser flate readers. These are pooled for connections.
Functions ¶
func MarshalPacket ¶
func UnmarshalPacket ¶
Types ¶
type DecodeReader ¶
type DecodeReader interface { io.Reader io.ByteReader }
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
NewDecoder returns a new decoder decoding data from the io.Reader passed. One read call from the reader is assumed to consume an entire packet.
type Disconnect ¶
type Disconnect struct { // HideDisconnectionScreen specifies if the disconnection screen should be hidden when the client is // disconnected, meaning it will be sent directly to the main menu. HideDisconnectionScreen bool // Message is an optional message to show when disconnected. This message is only written if the // HideDisconnectionScreen field is set to true. Message string }
Disconnect may be sent by the server to disconnect the client using an optional message to send as the disconnect screen.
type EncodeReader ¶
type EncodeReader interface { io.Writer io.ByteWriter }
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder handles the encoding of Minecraft packets that are sent to an io.Writer. The packets are compressed and optionally encoded before they are sent to the io.Writer.
func NewEncoder ¶
NewEncoder returns a new Encoder for the io.Writer passed. Each final packet produced by the Encoder is sent with a single call to io.Writer.Write().
type Login ¶
type Login struct { // ClientProtocol is the protocol version of the player. The player is disconnected if the protocol is // incompatible with the protocol of the server. ClientProtocol int32 // ConnectionRequest is a string containing information about the player and JWTs that may be used to // verify if the player is connected to XBOX Live. The connection request also contains the necessary // client public key to initiate encryption. ConnectionRequest []byte }
Login is sent when the client initially tries to join the server. It is the first packet sent and contains information specific to the player.
type Packet ¶
type Packet interface { // ID returns the ID of the packet. All of these identifiers of packets may be found in id.go. ID() uint32 // Unmarshal decodes a serialised packet in buf into the Packet instance. The serialised packet passed // into Unmarshal will not have a header in it. Unmarshal(r *Reader) error Marshal(w *Writer) }
Packet represents a packet that may be sent over a Minecraft network connection. The packet needs to hold a method to encode itself to binary and decode itself from binary.
type Reader ¶
type Reader struct {
DecodeReader
}
func NewReader ¶
func NewReader(r DecodeReader) *Reader