Overview
Key components:ConnectionRequest- Request to connect a player to a serverConnectionResult- Result of a connection attemptServerConnection- Active connection between player and server- Connection states and lifecycle management
pkg/edition/java/proxy/server.go
Connection Request
AConnectionRequest represents an intent to connect a player to a backend server.
Creating Connection Requests
RegisteredServer
required
The backend server to connect to.
Executing Connection Requests
Connect the player to the server:context.Context
required
Context for the connection operation. Use for timeouts and cancellation.
*ConnectionResult
The result of the connection attempt.
error
Error if the connection operation failed. Check the result for more details.
Connection Result
TheConnectionResult contains the outcome of a connection attempt.
Checking Success
bool
Returns true if the connection was successful and the player is now on the server.
Connection Attempt Status
Check if a connection was attempted:bool
Returns true if a connection to the server was actually attempted (even if it failed).
Getting Connection Reason
Retrieve the component explaining the connection result:component.Component
Returns the component explaining the result, or nil if no reason is available.
Server Connection
AServerConnection represents an active connection between a player and a backend server.
Source: pkg/edition/java/proxy/server.go:217
Getting Server Connection
Connection Properties
Access connection details:RegisteredServer
The backend server this connection is connected to.
Player
The player associated with this connection.
Connection State Management
The connection system manages various states during the connection lifecycle.Connection Phases
Connections go through several phases:- Handshake - Initial connection setup
- Login - Authentication with backend server
- Play - Active gameplay state
- Config - Configuration state (1.20.2+)
Graceful Disconnection
Connections track whether they were gracefully disconnected:Connection Events
The connection system fires events during the lifecycle:Server Pre-Connect Event
Called before a connection is attempted:Server Connected Event
Called when a player successfully connects:Server Disconnect Event
Called when a player disconnects from a server:Connection Timeout
Configure connection timeouts using context:Plugin Messages via Connection
Send plugin messages through the server connection:message.ChannelIdentifier
required
The plugin message channel.
[]byte
required
The message payload.
Complete Example
See Also
- Proxy API - Main proxy interface
- Player API - Player management
- Server API - Server registration and info
- Events Guide - Connection-related events

