server

package
Version: v0.1.1-0...-e483cfb Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGroup

func AddGroup(g *Group)

AddGroup stores a group in the groups map to be used for lookups.

func Groups

func Groups() map[string]*Group

Groups returns all of the groups registered on the proxy.

func RemoveGroup

func RemoveGroup(name string)

RemoveGroup removes a group from the map, meaning it can no longer be used for lookups etc.

func SetDefaultGroup

func SetDefaultGroup(g *Group)

SetDefaultGroup sets the default group that is commonly used for loading balancing.

Types

type Client

type Client interface {
	io.Closer

	// Name returns the name of the Client. This must be unique for all clients as it is used for
	// identification by the proxy and other clients.
	Name() string
	// ReadPacket reads a packet from the Client and returns it. It also returns an error in case one
	// occurred whilst reading the packet.
	ReadPacket() (packet.Packet, error)
	// ReadPacket writes a packet to the Client. It returns an error in case one occurred whilst writing the
	// packet.
	WritePacket(pk packet.Packet) error
}

Client represents a client connected over the TCP socket system.

type Group

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

Group represents a group of servers on the proxy. Groups are used to keep servers organized and in one place on the proxy, making it easier for servers to separate different parts of their network.

func DefaultGroup

func DefaultGroup() *Group

DefaultGroup returns the default group that is commonly used for load balancing.

func GroupFromName

func GroupFromName(name string) (*Group, bool)

GroupFromName attempts to find a group with the name provided. The group and a bool to say if the group is found or not is returned.

func NewGroup

func NewGroup(name string) *Group

NewGroup creates a new group with the given name and returns it.

func (*Group) AddServer

func (g *Group) AddServer(s *Server)

AddServer adds the provided server to the group, overriding existing ones if the name conflicts.

func (*Group) Name

func (g *Group) Name() string

Name returns the name the group was registered with.

func (*Group) RemoveServer

func (g *Group) RemoveServer(name string)

RemoveServer removes the provided server name from the group.

func (*Group) Server

func (g *Group) Server(name string) (*Server, bool)

Server attempts to find the server by the name provided. It returns the Server and a bool to say if the Server was found or not.

func (*Group) Servers

func (g *Group) Servers() map[string]*Server

Servers returns all of the servers connected to the group.

type Server

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

Server represents a server connected to the proxy which players can join and play on.

func New

func New(name, group, address string) *Server

New creates a new Server with the provided name, group and address.

func (*Server) Address

func (s *Server) Address() string

Address returns the IP address the server was registered with. This should also contain the port separated by a colon. E.g. "127.0.0.1:19132".

func (*Server) Conn

func (s *Server) Conn() Client

Conn returns the TCP socket client the server is connected to. If the server is not connected, this function returns nil.

func (*Server) Connected

func (s *Server) Connected() bool

Connected returns if the server is connected to the TCP socket server or not.

func (*Server) DecrementPlayerCount

func (s *Server) DecrementPlayerCount()

DecrementPlayerCount decreases the player count of the server.

func (*Server) Group

func (s *Server) Group() string

Group returns the name of the group the server was registered with.

func (*Server) IncrementPlayerCount

func (s *Server) IncrementPlayerCount()

IncrementPlayerCount increments the player count of the server.

func (*Server) Name

func (s *Server) Name() string

Name returns the name the server was registered with.

func (*Server) PlayerCount

func (s *Server) PlayerCount() int

PlayerCount returns the player count of the server controlled by the IncrementPlayerCount and DecrementPlayerCount functions above.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to