Documentation
¶
Overview ¶
Package session runs a play session: modlock-host with the mods, a Deadlock client that joins it, and the control link that reports the mods' progress and reloads them.
Index ¶
Constants ¶
const DeadlockAppID = "1422450"
DeadlockAppID is Deadlock's Steam application ID.
const DefaultInterfacePort = 4320
DefaultInterfacePort is the loopback port the relay page reads the mods' interfaces from.
const DefaultPort = 27067
DefaultPort is the server's default UDP port.
const DefaultRelay = "https://hyperline.gg"
DefaultRelay hosts the relay page the game reads the mods' interfaces through.
const HostArchive = "modlock-host-windows-x64.zip"
HostArchive is the release asset that holds the Windows host.
const RelayAgent = "Source2 HTML"
RelayAgent marks the game's own HTML panels in their User-Agent. Requiring it keeps the relay page, opened in an ordinary browser, from reading the player's screen. A Steam beta client names its branch after the marker, as "Source2 HTML [Steam Beta Update]/".
Variables ¶
var ErrNoGame = errors.New("this computer cannot run Deadlock")
ErrNoGame marks the errors that mean this computer cannot run a Deadlock server: the system is not Windows or Linux, or Steam or the game is missing.
Functions ¶
func DownloadHost ¶
DownloadHost returns modlock-host.exe from the release tagged version, downloading and extracting it into the user cache the first time.
func FindHost ¶
FindHost returns modlock-host.exe: MODLOCK_HOST when set, else the release matching version, downloaded once into the user cache.
func WindowsPath ¶
WindowsPath names an absolute Linux path as Wine's Z: drive sees it.
Types ¶
type Config ¶
type Config struct {
// Version is the command line's release, whose host the session runs
// unless MODLOCK_HOST names one.
Version string
// Mods lists the built mods to load.
Mods []string
// Port is the server's UDP port.
Port uint16
// Map is the map the server starts, or empty for the default.
Map string
// Args are passed to each mod's start handlers.
Args []string
// Settings is the file that keeps players' settings, or empty to keep
// them for the session only.
Settings string
// Launch starts the Deadlock client once the server is ready.
Launch bool
// HostOutput receives the host's console output.
HostOutput io.Writer
// Interface is the loopback address the player's game reads the mods'
// interfaces from, or empty to serve none.
Interface string
// Relay is the origin of the https page the game reads them through.
Relay string
// Events receives each host event, on one goroutine.
Events func(*control.HostEvent)
}
Config describes a play session.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control is the controller's end of the control link. It listens on a loopback port and modlock-host dials it with --control; then the host streams its events and takes reloads, each message framed by its length as control.proto describes.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is a running modlock-host process.
func StartHost ¶
func StartHost(ctx context.Context, config HostConfig) (*Host, error)
StartHost starts modlock-host as a listen server with the mods. On Windows the host runs directly; on Linux it runs through Steam's Proton in a prefix of its own.
type HostConfig ¶
type HostConfig struct {
// Executable is modlock-host.exe, beside its libraries.
Executable string
// GameDir is the Deadlock installation directory.
GameDir string
// Mods lists the built mods to load, as directories with mod.json.
Mods []string
// Control is the address of the controller's Control link.
Control string
// Port is the server's UDP port.
Port uint16
// Map is the map the server starts, or empty for the host's default.
Map string
// Args are passed to each mod's start handlers.
Args []string
// Settings is the file that keeps players' settings, or empty to keep
// them for the run only.
Settings string
// Steam is the Steam installation; on Linux its Proton runs the host.
Steam *Steam
// Output receives the host's console output.
Output io.Writer
}
HostConfig describes one modlock-host run.
type Proton ¶
type Proton struct {
// Dir is the Proton installation directory.
Dir string
// Prefix is the compatibility data directory of the host's prefix.
Prefix string
// contains filtered or unexported fields
}
Proton is one Steam Proton installation with the prefix modlock-host runs in. The prefix is the command line's own: the host must not share the game's prefix, because Steam runs the client under its own Proton, whose wineserver would wait for this one to exit.
func FindProton ¶
FindProton returns MODLOCK_PROTON when set, else the newest numbered Proton in the Steam libraries, else Proton Experimental.
type Screens ¶
type Screens struct {
// contains filtered or unexported fields
}
Screens keeps what the mods show the local player and serves it to the player's game on loopback. Deadlock loads only https pages into its HTML panels, so the game's renderer reads through a relay page from another origin: the page streams the screen from GET /panorama/stream, one JSON ui.Screen per line. The game presses buttons with a console command to the server, not through this page.
func NewScreens ¶
NewScreens returns screens for the player with the Steam ID account, read through the relay page from origin.
func (*Screens) Handle ¶
Handle follows one host event: a join that binds the local player's slot, a leave that frees it, or a mod's change to a player's interface.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a running play session: the host with the mods and, once the server is ready, the Deadlock client joined to it.
func Start ¶
Start starts the host with the mods and serves its control link. It returns an error marked ErrNoGame when this computer cannot run the game.
type Steam ¶
type Steam struct {
// Root is the Steam installation directory.
Root string
// Libraries lists every library directory, Root first.
Libraries []string
}
Steam is the local Steam installation: the client that launches games and the libraries they are installed in.
func (*Steam) Account ¶
Account returns the Steam ID of the account signed in to Steam last, or zero when Steam names none.
func (*Steam) App ¶
App returns the installation directory of the app installed as name, such as "Deadlock", in the first library that has it.