Documentation
¶
Index ¶
- type Handler
- type LoadBalancer
- type NopHandler
- type Session
- func (s *Session) Close()
- func (s *Session) Conn() *minecraft.Conn
- func (s *Session) Disconnect(message string)
- func (s *Session) Handle(h Handler)
- func (s *Session) Server() *server.Server
- func (s *Session) ServerConn() *minecraft.Conn
- func (s *Session) Transfer(srv *server.Server) (err error)
- func (s *Session) Transferring() bool
- func (s *Session) UUID() uuid.UUID
- type SimpleWhitelist
- type SplitLoadBalancer
- type Store
- type Whitelist
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { // HandleClientBoundPacket handles a packet that's sent by the session's connected server. ctx.Cancel() // may be called to cancel the packet. HandleClientBoundPacket(ctx *event.Context, pk packet.Packet) // HandleServerBoundPacket handles a packet that's sent by the session. ctx.Cancel() may be called to // cancel the packet. HandleServerBoundPacket(ctx *event.Context, pk packet.Packet) // HandleServerDisconnect handles the server connection getting closed. ctx.Cancel() may be called after // transferring the player to cancel disconnecting them. HandleServerDisconnect(ctx *event.Context) // HandleTransfer handles a session being transferred to another server. ctx.Cancel() may be called to // cancel the transfer. HandleTransfer(ctx *event.Context, svr *server.Server) // HandleQuit handles the closing of a session. It is always called when the session is disconnected, // regardless of the reason. HandleQuit() }
Handler handles events that are called by a player's session.
type LoadBalancer ¶
type LoadBalancer interface { // FindServer finds a server for the session to connect to when they first join. If nil is returned, the // player is kicked from the proxy. FindServer(session *Session) *server.Server }
LoadBalancer represents a load balancer which helps balance the load of players on the proxy.
type NopHandler ¶
type NopHandler struct{}
NopHandler implements the Handler interface but does not execute any code when an event is called. The default handler of sessions is set to NopHandler. Users may embed NopHandler to avoid having to implement each method.
func (NopHandler) HandleClientBoundPacket ¶
func (NopHandler) HandleClientBoundPacket(*event.Context, packet.Packet)
HandleClientBoundPacket ...
func (NopHandler) HandleServerBoundPacket ¶
func (NopHandler) HandleServerBoundPacket(*event.Context, packet.Packet)
HandleServerBoundPacket ...
func (NopHandler) HandleServerDisconnect ¶ added in v0.1.4
func (NopHandler) HandleServerDisconnect(*event.Context)
HandleServerDisconnect ...
func (NopHandler) HandleTransfer ¶
func (NopHandler) HandleTransfer(*event.Context, *server.Server)
HandleTransfer ...
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session stores the data for an active session on the proxy.
func New ¶
func New(conn *minecraft.Conn, store *Store, loadBalancer LoadBalancer, log internal.Logger) (s *Session, err error)
New creates a new Session with the provided connection.
func (*Session) Close ¶
func (s *Session) Close()
Close closes the session and any linked connections/counters.
func (*Session) Disconnect ¶ added in v0.2.0
Disconnect disconnects the session from the proxy and shows them the provided message. If the message is empty, the player will be immediately sent to the server list instead of seeing the disconnect screen.
func (*Session) Handle ¶
Handle sets the handler for the current session which can be used to handle different events from the session. If the handler is nil, a NopHandler is used instead.
func (*Session) ServerConn ¶
ServerConn returns the connection for the session's current server.
func (*Session) Transfer ¶
Transfer transfers the session to the provided server, returning any error that may have occurred during the initial transfer.
func (*Session) Transferring ¶
Transferring returns if the session is currently transferring to a different server or not.
type SimpleWhitelist ¶ added in v0.2.0
type SimpleWhitelist struct {
// contains filtered or unexported fields
}
SimpleWhitelist is a whitelist that, if enabled, only allows a set list of players to join.
func NewSimpleWhitelist ¶ added in v0.2.0
func NewSimpleWhitelist(enabled bool, players []string) *SimpleWhitelist
NewSimpleWhitelist returns a simple whitelist from the enabled status and a player list passed.
type SplitLoadBalancer ¶ added in v0.2.0
type SplitLoadBalancer struct {
// contains filtered or unexported fields
}
SplitLoadBalancer attempts to split players evenly across all the servers.
func NewSplitLoadBalancer ¶ added in v0.2.0
func NewSplitLoadBalancer(registry *server.Registry) *SplitLoadBalancer
NewSplitLoadBalancer creates a "split" load balancer with the provided server registry.
func (*SplitLoadBalancer) FindServer ¶ added in v0.2.0
func (b *SplitLoadBalancer) FindServer(*Session) (srv *server.Server)
FindServer ...
type Store ¶ added in v0.2.0
type Store struct {
// contains filtered or unexported fields
}
Store represents a store which holds all the open sessions on the proxy.
func NewDefaultStore ¶ added in v0.2.0
func NewDefaultStore() *Store
NewDefaultStore creates a new Store and returns it.
func (*Store) LoadFromName ¶ added in v0.2.0
LoadFromName attempts to load a session from the username of a player.
type Whitelist ¶ added in v0.2.0
type Whitelist interface { // Authorize returns whether a player with the given connection is allowed to join the proxy and a message // to display to the player on their disconnection screen. Authorize(conn *minecraft.Conn) (bool, string) }
Whitelist handles the players joining the proxy to decide which are allowed join.