ping

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JavaEdition    string = "java"
	BedrockEdition string = "bedrock"
)
View Source
const (
	// Default ping timeout
	DefaultTimeout = time.Second * 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BedrockPinger

type BedrockPinger struct {
	Port    uint16
	Host    string
	Timeout time.Duration
}

Minecraft server pinger using go-bedrockping

func (*BedrockPinger) IsTimeoutZero

func (p *BedrockPinger) IsTimeoutZero() bool

Checks if the current timeout duration is zero

func (*BedrockPinger) Ping

func (p *BedrockPinger) Ping() (*ServerInfo, error)

Pings the bedrock minecraft server and returns server info. Returns error on failed ping

func (*BedrockPinger) PingWithTimeout

func (p *BedrockPinger) PingWithTimeout() (*ServerInfo, error)

Pings the bedrock minecraft server and returns server info. Returns error on failed ping or timeout

type McPinger

type McPinger struct {
	Port    uint16
	Host    string
	Timeout time.Duration
}

Minecraft server pinger using mc-pinger

func (*McPinger) IsTimeoutZero

func (p *McPinger) IsTimeoutZero() bool

Checks if the current timeout duration is zero

func (*McPinger) Ping

func (p *McPinger) Ping() (*ServerInfo, error)

Pings minecraft server and returns info obj. Returns error on failed ping

func (*McPinger) PingWithTimeout

func (p *McPinger) PingWithTimeout() (*ServerInfo, error)

Pings minecraft server and return info obj. Return error on failed ping or timed out context

type Pinger

type Pinger interface {
	Ping() (*ServerInfo, error)
	PingWithTimeout() (*ServerInfo, error)
	IsTimeoutZero() bool
}

Interface for pinger implementation

type ServerInfo

type ServerInfo struct {
	Protocol      int32
	Version       string
	MaxPlayers    int32
	OnlinePlayers int32
}

type ServerPinger

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

Minecraft server pinger and SDK state manager

func New

func New(host string, port uint16, edition string) (*ServerPinger, error)

Creates a new AgonesPinger with that will ping the minecraft server at the given host and on the given port. Also initializes a connection with the local Agones server on localhost port 9357. Blocks until connection and handshake is made. Timesout and returns an error after 30 seconds

func NewTimed

func NewTimed(host string, port uint16, timeout time.Duration, edition string) (*ServerPinger, error)

Creates a new AgonesPinger with that will ping the minecraft server at the given host and on the given port. Ping will timeout after the give timeout duration. Also initializes a connection with the local Agones server on localhost port 9357. Blocks until connection and handshake is made. Timesout and returns an error after 30 seconds

func (*ServerPinger) HealthPing

func (p *ServerPinger) HealthPing() error

Pings the minecraft server and sends Health() signal to the local Agones server on localhost port 9357 Returns an error if the ping is unsuccessful

func (*ServerPinger) HealthPingWithTimeout

func (p *ServerPinger) HealthPingWithTimeout() error

Pings the minecraft server and sends Health() signal to the local Agones server on localhost port 9357 Returns an error if the ping is unsuccessful or timeouts

func (*ServerPinger) ReadyPing

func (p *ServerPinger) ReadyPing() error

Pings the minecraft server and sends Ready() signal to the local Agones server on localhost port 9357 Returns an error if the ping is unsuccessful

func (*ServerPinger) ReadyPingWithTimeout

func (p *ServerPinger) ReadyPingWithTimeout() error

Pings the minecraft server and sends Ready() signal to the local Agones server on localhost port 9357 Returns an error if the ping is unsuccessful or timeouts

type StartingUpErr

type StartingUpErr struct{}

Custom Error for failed pings due to server startup

func (StartingUpErr) Error

func (e StartingUpErr) Error() string

Jump to

Keyboard shortcuts

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