ping

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 3 Imported by: 3

Documentation

Overview

ping package implements the mincraft Server List Ping protocol. This package is strictly compliant with the following documentation : https://wiki.vg/Server_List_Ping

Index

Constants

View Source
const (
	UnknownProtocolVersion int32  = -1
	HandshakePacketID      uint32 = 0
	PingPacketID           uint32 = 1
)

Variables

This section is empty.

Functions

func Ping

func Ping(hostname string, port int) (map[string]interface{}, int, error)

Ping returns the server list ping infos (JSON-like object), and latency of a minecraft server. If an error occured at any point of the process, an nil json response, a latency of -1, and a non nil error are returned.

Types

type Handshake

type Handshake struct {
	Properties map[string]interface{} `json:"properties"`
}

type PingClient

type PingClient struct {
	// contains filtered or unexported fields
}

PingClient is the ping client.

func NewClient

func NewClient(hostname string, port int) *PingClient

NewClient returns a well-formed *PingClient.

func (*PingClient) Connect

func (client *PingClient) Connect() error

Connect establishes a connection via TCP.

func (*PingClient) Disconnect

func (client *PingClient) Disconnect() error

Disconnect closes the connection. Connection is made not usable anymore no matter if the it closed properly or not.

func (*PingClient) Handshake

func (client *PingClient) Handshake() (Handshake, error)

Handshake sends a handshake request to the server, and returns the formatted result.

func (*PingClient) Ping

func (client *PingClient) Ping() (int, error)

Ping sends a ping request to the server, and returns the latency in ms. A ping request must be done after a handshake request has already been done.

func (*PingClient) SetDialOptions

func (client *PingClient) SetDialOptions(dialOptions networking.DialTCPOptions)

SetDialOptions sets the options used in the dial process of the connection.

Jump to

Keyboard shortcuts

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