Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
func Listen() error
Listen starts a TCP listener on the configured address to handle incoming connections.
func RegisterHandler ¶
func RegisterHandler(id uint16, h PacketHandler)
RegisterHandler registers a PacketHandler for the provided packet ID. Handlers do not stack, meaning registering multiple handlers for the same id will override the previous one.
func ReportPlayerLatency ¶
ReportPlayerLatency sends the latency of each player to their connected server at the interval provided.
Types ¶
type AuthRequestHandler ¶
type AuthRequestHandler struct{}
AuthRequestHandler is responsible for handling the AuthRequest packet sent by servers.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client connected over the TCP socket system.
func NewClient ¶
NewClient creates a new socket Client with default allocations and required data. It pre-allocates 4096 bytes to prevent allocations during runtime as much as possible.
func (*Client) ReadPacket ¶
ReadPacket reads a packet from the connection and returns it. The client is expected to prefix the packet payload with 4 bytes for the length of the payload.
type FindPlayerRequestHandler ¶
type FindPlayerRequestHandler struct{}
FindPlayerRequestHandler is responsible for handling the FindPlayerRequest packet sent by servers.
type PacketHandler ¶
type PacketHandler interface { // Handle is responsible for handling an incoming packet for the client. Handle(p packet.Packet, c *Client) error }
PacketHandler represents a type which handles a specific packet coming from a client.
type PlayerInfoRequestHandler ¶
type PlayerInfoRequestHandler struct{}
PlayerInfoRequestHandler is responsible for handling the PlayerInfoRequest packet sent by servers.
type ServerListRequestHandler ¶
type ServerListRequestHandler struct{}
ServerListRequestHandler is responsible for handling the ServerListRequest packet sent by servers.
type TransferRequestHandler ¶
type TransferRequestHandler struct{}
TransferRequestHandler is responsible for handling the TransferRequest packet sent by servers.