packet

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IDConnectionRequest = iota + 500
	IDConnectionResponse
	IDLatency
	IDTransfer
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionRequest

type ConnectionRequest struct {
	// Addr is the address of the player.
	Addr string
	// Token is the proxy's token that's used for authorization by the server.
	Token string
	// ClientData is the player's login.ClientData.
	ClientData []byte
	// IdentityData is the player's login.IdentityData.
	IdentityData []byte
}

ConnectionRequest is the initial packet sent by the proxy to the server. The server responds to this packet with a ConnectionResponse packet.

func (*ConnectionRequest) ID

func (pk *ConnectionRequest) ID() uint32

ID ...

func (*ConnectionRequest) Marshal

func (pk *ConnectionRequest) Marshal(io protocol.IO)

Marshal ...

type ConnectionResponse

type ConnectionResponse struct {
	// RuntimeID is the deterministic runtime ID of the player.
	RuntimeID uint64
	// UniqueID is the deterministic unique ID of the player.
	UniqueID int64
}

ConnectionResponse is sent by the server in response to a ConnectionRequest. It includes unique and deterministic identifiers for the player's connection. Both RuntimeID and UniqueID remain unchanged throughout the player's session, ensuring consistency across all servers the player transfers or connects to.

func (*ConnectionResponse) ID

func (pk *ConnectionResponse) ID() uint32

ID ...

func (*ConnectionResponse) Marshal

func (pk *ConnectionResponse) Marshal(io protocol.IO)

Marshal ...

type Latency

type Latency struct {
	// Latency is the measured latency in milliseconds.
	Latency int64
	// Timestamp is the timestamp (in milliseconds) when the latency measurement was sent.
	Timestamp int64
}

Latency is used for latency measurement between a client connected to the proxy and the server: 1. Proxy sends a Latency packet with the current timestamp and the client's ping. 2. Server measures the time taken for the packet to arrive and adds the client's latency. 3. Server responds with a Latency packet containing the total calculated latency.

func (*Latency) ID

func (pk *Latency) ID() uint32

ID ...

func (*Latency) Marshal

func (pk *Latency) Marshal(io protocol.IO)

Marshal ...

type Transfer

type Transfer struct {
	// Addr is the address of the new server.
	Addr string
}

Transfer is sent by the server to initiate a server transfer.

func (*Transfer) ID

func (pk *Transfer) ID() uint32

ID ...

func (*Transfer) Marshal

func (pk *Transfer) Marshal(io protocol.IO)

Marshal ...

Jump to

Keyboard shortcuts

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