control

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package control handles incoming requests and actions.

The Controller type wraps a LaunchManager and implements HTTP handlers for it.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("unsupported script")

ErrUnsupported is returned when the script can't be loaded by any scriptplayer.

View Source
var Loaders = []Loader{
	{
		Loader: &funscript.Loader{},
		ContentTypes: []string{
			"application/prs.funscript+json",
			"application/json",
		},
	},
	{
		Loader: protocol.LoaderFunc(raw.Load),
		ContentTypes: []string{
			"application/prs.launchcontrol+json",
			"application/json",
		},
	},
	{
		Loader: protocol.LoaderFunc(kiiroo.Load),
		ContentTypes: []string{
			"text/prs.kiiroo",
			"x-text/kiiroo",
			"text/plain",
		},
	},
	{
		Loader: protocol.LoaderFunc(kiiroo.LoadText),
		ContentTypes: []string{
			"text/plain",
		},
	},
	{
		Loader: protocol.LoaderFunc(kiiroo.LoadJSON),
		ContentTypes: []string{
			"application/prs.kiiroo+json",
			"application/json",
		},
	},
}

Loaders contains all the registered ScriptLoaders.

Functions

func LoadScript

func LoadScript(r io.Reader, contentType string, p Personalization) (protocol.Player, error)

LoadScript tries to load specified script with all ScriptPlayers and returns the first one that's succesfull. Loaders that are tried can be filtered by specifying the content type.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller translates http requests into manager actions.

func NewController

func NewController(m *device.LaunchManager) *Controller

NewController returns a new controller for the given manager.

func (*Controller) DumpHandler

func (c *Controller) DumpHandler(w http.ResponseWriter, r *http.Request)

DumpHandler is a http.Handler to dump the current script.

func (*Controller) PauseHandler

func (c *Controller) PauseHandler(w http.ResponseWriter, r *http.Request)

PauseHandler is a http.Handler to pause playback.

func (*Controller) PlayHandler

func (c *Controller) PlayHandler(w http.ResponseWriter, r *http.Request)

PlayHandler is a http.Handler to load and play scripts.

func (*Controller) ResumeHandler

func (c *Controller) ResumeHandler(w http.ResponseWriter, r *http.Request)

ResumeHandler is a http.Handler to resume playback.

func (*Controller) SkipHandler

func (c *Controller) SkipHandler(w http.ResponseWriter, r *http.Request)

SkipHandler is a http.Handler to jump to a given timecode.

func (*Controller) StopHandler

func (c *Controller) StopHandler(w http.ResponseWriter, r *http.Request)

StopHandler is a http.Handler to stop playback.

func (*Controller) WebsocketHandler

func (c *Controller) WebsocketHandler(w http.ResponseWriter, r *http.Request)

WebsocketHandler implements http.Handler that reponds with a websocket writing status messages in JSON.

type Loader

type Loader struct {
	Loader       protocol.Loader
	ContentTypes []string
}

Loader wraps a scriptloader with it's supported mediatypes.

func (Loader) IsSupported

func (l Loader) IsSupported(contentType string) bool

IsSupported checks if the loader can handle specified content type.

type Personalization

type Personalization struct {
	Latency     time.Duration
	PositionMin int // Lowest position
	PositionMax int // Highest position
	SpeedMin    int // Slowest speed to move at
	SpeedMax    int // Fastest speed to move at
}

Personalization are settings customizing a scripts behaviour

func NewPersonalization

func NewPersonalization() Personalization

NewPersonalization return a Personalization with the default values.

Jump to

Keyboard shortcuts

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