mgmt

package
v0.0.0-...-507577e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package mgmt contains the logic for managing game engines. This includes downloading engines and fetch available engine configurations. It uses the conf package to connect to the EVC server and deterime the engine store location.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadEngine

func DownloadEngine(inst *EngineInstance) error

DownloadEngine downloads the given engine instance and saves it to the engine store.

func GetAvailableEngines

func GetAvailableEngines(defaultEngine string) (*[]Engine, error)

GetAvailableEngines returns a list of available engines. If defaultEngine is not empty, only the default engine will be returned.

Types

type Connection

type Connection struct {
	Pid int
	// contains filtered or unexported fields
}

Connection is a wrapper for the communication between the adapter and the engine. It provides a simple interface to send commands to the engine and receive its responses.

func LaunchEngine

func LaunchEngine(path string, scb func(string), rcb func(string)) (*Connection, error)

LaunchEngine launches an engine executable at the given path and returns a connection to it. The connection is used to communicate with the engine using channels. If the engine instance could not be launched, an error is returned and the connection is nil.

func NewConnection

func NewConnection(pid int, in chan string, out chan string) *Connection

NewConnection creates a new connection between the adapter and the engine. It returns a pointer to the connection.

func (*Connection) Expect

func (conn *Connection) Expect(cmd string, cnf string) []string

Expect sends a command to the engine and waits for a confirmation. If the confirmation is received, the function returns a slice of strings containing the responses from the engine.

func (*Connection) Line

func (conn *Connection) Line() string

Line sends a command to the engine and waits for a response. The response is returned as a string.

func (*Connection) Next

func (conn *Connection) Next() string

Next returns the next response from the engine.

func (*Connection) Read

func (conn *Connection) Read(filter func(resp string) bool)

Read reads the responses from the engine until the filter function returns true.

func (*Connection) Scan

func (conn *Connection) Scan(cmd string, filter func(resp string) bool)

Scan sends a command to the engine and waits for a response. The response is returned as a string. The response is passed to the filter function. If the filter function returns true, the function returns.

func (*Connection) Send

func (conn *Connection) Send(cmd string)

Send sends a command to the engine.

type Engine

type Engine struct {
	Name       string      `json:"name"`
	Variations []Variation `json:"variations"`
}

Engine is a struct that represents a game engine.

func (*Engine) GetInstances

func (e *Engine) GetInstances() []EngineInstance

GetInstances returns a slice of EngineInstance structs that represent all the versions of the engine.

type EngineInstance

type EngineInstance struct {
	Engine  string
	Version Version
	Id      string
}

EngineInstance is a struct that represents a specific instance of a game engine. This is used to represent a specific version of a game engine.

func BestMatch

func BestMatch(name string, version Version) (*EngineInstance, error)

func GetEngineInstance

func GetEngineInstance(engine string, version string) (*EngineInstance, error)

GetEngineInstance returns an EngineInstance for the given engine and version.

func (EngineInstance) FileName

func (inst EngineInstance) FileName() string

FileName returns the file name of the engine instance.

func (EngineInstance) IsInstalled

func (inst EngineInstance) IsInstalled() bool

IsInstalled returns whether the engine instance is installed.

func (*EngineInstance) Launch

func (e *EngineInstance) Launch(scb func(string), rcb func(string)) (*Connection, error)

Launch launches the engine instance and returns a connection to it. The connection is used to communicate with the engine using channels. If the engine instance could not be launched, an error is returned and the connection is nil.

func (EngineInstance) Path

func (inst EngineInstance) Path() string

Path returns the path to the engine instance. The conf package is used to determine the engine store location.

func (EngineInstance) URL

func (inst EngineInstance) URL() string

URL returns the URL to the engine instance on the EVC server.

type Flavour

type Flavour struct {
	Id           string   `json:"id"`
	Os           string   `json:"os"`
	Arch         string   `json:"arch"`
	Capabilities []string `json:"capabilities"`
}

type Variation

type Variation struct {
	Version  Version   `json:"version"`
	Flavours []Flavour `json:"flavours"`
}

type Version

type Version struct {
	Major int `json:"major"`
	Minor int `json:"minor"`
	Patch int `json:"patch"`
}

Version is a struct that represents a version of a game engine.

func ParseVersion

func ParseVersion(ver string, style VersionStyle) (*Version, error)

ParseVersion parses a version string and returns a Version struct. If style is 'DotVersionStyle', the version string must be in the format of "$major.$minor.$patch". If style is 'UrlSaveVersionStyle', the version string must be in the format of "$major-$minor-$patch". A leading 'v' is ignored.

func (Version) Equals

func (v Version) Equals(other Version) bool

func (*Version) String

func (v *Version) String(style VersionStyle) string

String returns a string representation of the version. If style is 'DotVersionStyle', the version will be returned in the format of "$major.$minor.$patch". If style is 'UrlSaveVersionStyle', the version will be returned in the format of "v$major-$minor-$patch".

type VersionStyle

type VersionStyle int

VersionStyle is an enum that represents the style of a version string.

const (
	DotVersionStyle     VersionStyle = iota // DotVersionStyle is the style of a version string that uses dots.
	UrlSaveVersionStyle                     // UrlSaveVersionStyle is the style of a version string that uses dashes.
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL