Documentation
¶
Index ¶
- type Context
- type NopProcessor
- func (NopProcessor) ProcessClient(_ *Context, _ packet.Packet)
- func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessDisconnection(_ *Context)
- func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string)
- func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string)
- func (NopProcessor) ProcessServer(_ *Context, _ packet.Packet)
- func (NopProcessor) ProcessServerEncoded(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessStartGame(_ *Context, _ *minecraft.GameData)
- type Processor
- type Registry
- type Session
- func (s *Session) Animation() animation.Animation
- func (s *Session) Client() *minecraft.Conn
- func (s *Session) Close() (err error)
- func (s *Session) Disconnect(message string)
- func (s *Session) Latency() int64
- func (s *Session) Login() (err error)
- func (s *Session) LoginContext(ctx context.Context) (err error)
- func (s *Session) LoginTimeout(duration time.Duration) (err error)
- func (s *Session) Opts() util.Opts
- func (s *Session) Processor() Processor
- func (s *Session) Server() *server.Conn
- func (s *Session) SetAnimation(animation animation.Animation)
- func (s *Session) SetOpts(opts util.Opts)
- func (s *Session) SetProcessor(processor Processor)
- func (s *Session) Transfer(addr string) (err error)
- func (s *Session) TransferContext(ctx context.Context, addr string) (err error)
- func (s *Session) TransferTimeout(addr string, duration time.Duration) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶ added in v0.0.23
type Context struct {
// contains filtered or unexported fields
}
Context represents the context of an action. It holds the state of whether the action has been canceled.
type NopProcessor ¶ added in v0.0.23
type NopProcessor struct{}
NopProcessor is a no-operation implementation of the Processor interface.
func (NopProcessor) ProcessClient ¶ added in v0.0.23
func (NopProcessor) ProcessClient(_ *Context, _ packet.Packet)
func (NopProcessor) ProcessClientEncoded ¶ added in v0.0.26
func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessDisconnection ¶ added in v0.0.23
func (NopProcessor) ProcessDisconnection(_ *Context)
func (NopProcessor) ProcessPostTransfer ¶ added in v0.0.23
func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessPreTransfer ¶ added in v0.0.23
func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessServer ¶ added in v0.0.23
func (NopProcessor) ProcessServer(_ *Context, _ packet.Packet)
func (NopProcessor) ProcessServerEncoded ¶ added in v0.0.26
func (NopProcessor) ProcessServerEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessStartGame ¶ added in v0.0.23
func (NopProcessor) ProcessStartGame(_ *Context, _ *minecraft.GameData)
type Processor ¶
type Processor interface { // ProcessStartGame is called only once during the login sequence. ProcessStartGame(ctx *Context, data *minecraft.GameData) // ProcessServer is called before forwarding the server-sent packets to the client. ProcessServer(ctx *Context, pk packet.Packet) // ProcessServerEncoded is called before forwarding the server-sent packets to the client. ProcessServerEncoded(ctx *Context, pk *[]byte) // ProcessClient is called before forwarding the client-sent packets to the server. ProcessClient(ctx *Context, pk packet.Packet) // ProcessClientEncoded is called before forwarding the client-sent packets to the server. ProcessClientEncoded(ctx *Context, pk *[]byte) // ProcessPreTransfer is called before transferring the player to a different server. ProcessPreTransfer(ctx *Context, origin *string, target *string) // ProcessPostTransfer is called after transferring the player to a different server. ProcessPostTransfer(ctx *Context, origin *string, target *string) // ProcessDisconnection is called when the player disconnects from the proxy. ProcessDisconnection(ctx *Context) }
Processor defines methods for processing various actions within a proxy session.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) AddSession ¶
func (*Registry) GetSession ¶
func (*Registry) GetSessionByUsername ¶
func (*Registry) GetSessions ¶
func (*Registry) RemoveSession ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a player session within the proxy, managing client and server interactions, including transfers, fallbacks, and tracking various session states.
func NewSession ¶
func NewSession(clientConn *minecraft.Conn, logger *slog.Logger, registry *Registry, discovery server.Discovery, opts util.Opts, transport transport.Transport) *Session
NewSession creates a new Session instance using the provided minecraft.Conn.
func (*Session) Animation ¶ added in v0.0.4
Animation returns the animation set to be played during server transfers.
func (*Session) Disconnect ¶
Disconnect sends a packet.Disconnect to the client and closes the session.
func (*Session) Latency ¶
Latency returns the total latency experienced by the session, combining client and server latencies. Note: The client's latency is derived from half of RakNet's round-trip time (RTT). To calculate the total latency, we multiply this value by 2.
func (*Session) Login ¶ added in v0.0.18
Login initiates the login sequence with a default timeout of 1 minute.
func (*Session) LoginContext ¶ added in v0.0.23
LoginContext initiates the login sequence for the session, including server discovery, establishing a connection, and spawning the player in the game. The process is performed using the provided context for cancellation.
func (*Session) LoginTimeout ¶ added in v0.0.23
LoginTimeout initiates the login sequence with the specified timeout duration.
func (*Session) SetAnimation ¶
SetAnimation sets the animation to be played during server transfers.
func (*Session) SetProcessor ¶
SetProcessor sets a new processor for the session.
func (*Session) Transfer ¶
Transfer initiates a transfer to a different server using the specified address. It sets a default timeout of 1 minute for the transfer operation.
func (*Session) TransferContext ¶ added in v0.0.23
TransferContext initiates a transfer to a different server using the specified address. It ensures that only one transfer occurs at a time, returning an error if another transfer is already in progress. The process is performed using the provided context for cancellation.