handler

package
v0.0.0-...-f92d382 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2016 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package handler is a wrapper around the ping package to listen and handle connections for displaying information to Minecraft clients.

Index

Constants

This section is empty.

Variables

View Source
var OnForwardConnect func(ipAddress string)

OnForwardConnect is called whenever a connection is forwarded to the given IP address, excluding server list pings.

View Source
var OnForwardDisconnect func(ipAddress string, duration time.Duration)

OnForwardDisconnect is called when a forwarded connection is closed from the given IP address, excluding server list pings.

Functions

func ClearHandlers

func ClearHandlers(hostnames []string)

ClearHandlers clears any connection handlers from Handle and Forward binded to the given list of hostnames.

func ClearStatus

func ClearStatus(hostnames []string)

ClearStatus clears the current status that was to be displayed on the server list for the given matching hostnames.

func Forward

func Forward(hostnames []string, address string)

Forward forwards the connection to the specified address when a player attempts to connect to the server with the given list of hostnames. The address MUST include the port number (usually 25565). Overrides any handlers set by Handle, and also forwards any server list status requests, but does NOT override any statuses stored. If you call Handle again, the previously used Status will be used.

func Handle

func Handle(hostnames []string, handler Handler)

Handle sets the handler function that is called when a player attempts to connect to the server with the given list of hostnames. The function should return the message to be displayed to the player. Overrides any handlers set by Forward.

func Listen

func Listen(port string) error

Listen listens on the specified port to serve Minecraft protocol requests.

func SetStatus

func SetStatus(hostnames []string, status *ping.Status)

SetStatus sets the current status that is to be displayed on the server list for the given matching hostnames.

func Stop

func Stop()

Stop stops the listener and causes Listen to return.

Types

type Handler

type Handler func(player *Player) (message string)

A Handler is used for handling when a player attempts to connect to the server. See Handle.

type Player

type Player struct {
	IPAddress      string
	Username       string
	Hostname       string
	ShouldClose    bool
	ForwardAddress string
	InitialPacket  *protocol.Packet
	State          int
	Stream         protocol.Stream
	Connection     net.Conn
}

Player is the container for the information of a player and their connection. See OnConnect.

Jump to

Keyboard shortcuts

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