Documentation
¶
Index ¶
- func RegisterHandler(id uint16, h PacketHandler)
- type AuthRequestHandler
- type Client
- type DefaultServer
- func (s *DefaultServer) Authenticate(c *Client, name string)
- func (s *DefaultServer) Client(name string) (*Client, bool)
- func (s *DefaultServer) Clients() (clients []*Client)
- func (s *DefaultServer) Listen() error
- func (s *DefaultServer) Logger() internal.Logger
- func (s *DefaultServer) ReportPlayerLatency(interval time.Duration)
- func (s *DefaultServer) Secret() string
- func (s *DefaultServer) ServerRegistry() *server.Registry
- func (s *DefaultServer) SessionStore() *session.Store
- type FindPlayerRequestHandler
- type PacketHandler
- type PlayerInfoRequestHandler
- type RegisterServerHandler
- type Server
- type ServerListRequestHandler
- type TransferRequestHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandler ¶
func RegisterHandler(id uint16, h PacketHandler)
RegisterHandler registers a PacketHandler for the provided packet ID. Handlers do not stack, meaning registering multiple handlers for the same id will override the previous one.
Types ¶
type AuthRequestHandler ¶
type AuthRequestHandler struct{}
AuthRequestHandler is responsible for handling the AuthRequest packet sent by servers.
func (*AuthRequestHandler) RequiresAuth ¶ added in v0.2.0
func (*AuthRequestHandler) RequiresAuth() bool
RequiresAuth ...
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client connected over the TCP socket system.
func NewClient ¶
NewClient creates a new socket Client with default allocations and required data. It pre-allocates 4096 bytes to prevent allocations during runtime as much as possible.
func (*Client) Authenticate ¶ added in v0.2.0
Authenticate marks the client as authenticated and gives it the provided name.
func (*Client) Authenticated ¶ added in v0.2.0
Authenticated returns if the client has been authenticated or not.
func (*Client) ReadPacket ¶
ReadPacket reads a packet from the connection and returns it. The client is expected to prefix the packet payload with 4 bytes for the length of the payload.
type DefaultServer ¶ added in v0.2.0
type DefaultServer struct {
// contains filtered or unexported fields
}
DefaultServer represents a basic TCP socket server implementation. It allows external connections to connect and authenticate to be able to communicate with the proxy.
func NewDefaultServer ¶ added in v0.2.0
func NewDefaultServer(addr, secret string, sessionStore *session.Store, serverRegistry *server.Registry, log internal.Logger, readerLimits bool) *DefaultServer
NewDefaultServer creates a new default server to be used for accepting socket connections.
func (*DefaultServer) Authenticate ¶ added in v0.2.0
func (s *DefaultServer) Authenticate(c *Client, name string)
Authenticate ...
func (*DefaultServer) Client ¶ added in v0.2.0
func (s *DefaultServer) Client(name string) (*Client, bool)
Client ...
func (*DefaultServer) Clients ¶ added in v0.2.0
func (s *DefaultServer) Clients() (clients []*Client)
Clients ...
func (*DefaultServer) Logger ¶ added in v0.2.0
func (s *DefaultServer) Logger() internal.Logger
Logger ...
func (*DefaultServer) ReportPlayerLatency ¶ added in v0.2.0
func (s *DefaultServer) ReportPlayerLatency(interval time.Duration)
ReportPlayerLatency sends the latency of each player to their connected server at the interval provided.
func (*DefaultServer) ServerRegistry ¶ added in v0.2.0
func (s *DefaultServer) ServerRegistry() *server.Registry
ServerRegistry ...
func (*DefaultServer) SessionStore ¶ added in v0.2.0
func (s *DefaultServer) SessionStore() *session.Store
SessionStore ...
type FindPlayerRequestHandler ¶
type FindPlayerRequestHandler struct {
// contains filtered or unexported fields
}
FindPlayerRequestHandler is responsible for handling the FindPlayerRequest packet sent by servers.
func (*FindPlayerRequestHandler) RequiresAuth ¶ added in v0.2.0
func (*FindPlayerRequestHandler) RequiresAuth() bool
RequiresAuth ...
type PacketHandler ¶
type PacketHandler interface { // Handle is responsible for handling an incoming packet for the client. Handle(p packet.Packet, src Server, c *Client) error // RequiresAuth returns if the client must be authenticated in order for the handler to be triggered. RequiresAuth() bool }
PacketHandler represents a type which handles a specific packet coming from a client.
type PlayerInfoRequestHandler ¶
type PlayerInfoRequestHandler struct {
// contains filtered or unexported fields
}
PlayerInfoRequestHandler is responsible for handling the PlayerInfoRequest packet sent by servers.
func (*PlayerInfoRequestHandler) RequiresAuth ¶ added in v0.2.0
func (*PlayerInfoRequestHandler) RequiresAuth() bool
RequiresAuth ...
type RegisterServerHandler ¶ added in v0.2.0
type RegisterServerHandler struct {
// contains filtered or unexported fields
}
RegisterServerHandler is responsible for handling the RegisterServer packet sent by servers.
func (*RegisterServerHandler) RequiresAuth ¶ added in v0.2.0
func (*RegisterServerHandler) RequiresAuth() bool
RequiresAuth ...
type Server ¶ added in v0.2.0
type Server interface { // Listen starts listening for connections on an address. Listen() error // Logger returns the logger attached to the socket server. Logger() internal.Logger // Secret returns the secret required for connections to authenticate. Secret() string // Clients returns all the clients that are connected to the socket server. Clients() []*Client // Client attempts to return a client from the provided name, case-sensitive. Client(name string) (*Client, bool) // Authenticate marks the client as authenticated with the provided name. It is safe to assume that the provided // name is not in use, unless called by places other than the socket server. Authenticate(c *Client, name string) // SessionStore returns the store used to hold the open sessions on the proxy. SessionStore() *session.Store // ServerRegistry returns the registry used to store available servers on the proxy. ServerRegistry() *server.Registry }
type ServerListRequestHandler ¶
type ServerListRequestHandler struct {
// contains filtered or unexported fields
}
ServerListRequestHandler is responsible for handling the ServerListRequest packet sent by servers.
func (*ServerListRequestHandler) RequiresAuth ¶ added in v0.2.0
func (*ServerListRequestHandler) RequiresAuth() bool
RequiresAuth ...
type TransferRequestHandler ¶
type TransferRequestHandler struct {
// contains filtered or unexported fields
}
TransferRequestHandler is responsible for handling the TransferRequest packet sent by servers.
func (*TransferRequestHandler) RequiresAuth ¶ added in v0.2.0
func (*TransferRequestHandler) RequiresAuth() bool
RequiresAuth ...