-
Notifications
You must be signed in to change notification settings - Fork 96
/
login.go
38 lines (33 loc) · 1.15 KB
/
login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package packet
import (
"bytes"
"encoding/binary"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// 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 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
}
// ID ...
func (*Login) ID() uint32 {
return IDLogin
}
// Marshal ...
func (pk *Login) Marshal(buf *bytes.Buffer) {
_ = binary.Write(buf, binary.BigEndian, pk.ClientProtocol)
_ = protocol.WriteByteSlice(buf, pk.ConnectionRequest)
}
// Unmarshal ...
func (pk *Login) Unmarshal(buf *bytes.Buffer) error {
return chainErr(
binary.Read(buf, binary.BigEndian, &pk.ClientProtocol),
protocol.ByteSlice(buf, &pk.ConnectionRequest),
)
}