server

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2015 License: ISC Imports: 32 Imported by: 0

Documentation

Overview

Package server implements the mog protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir added in v0.0.7

func Dir(useLocal bool, name string) http.FileSystem

Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.

func FS

func FS(useLocal bool) http.FileSystem

FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSByte added in v0.0.5

func FSByte(useLocal bool, name string) ([]byte, error)

FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSMustByte added in v0.0.5

func FSMustByte(useLocal bool, name string) []byte

FSMustByte is the same as FSByte, but panics if name is not present.

func FSMustString added in v0.0.5

func FSMustString(useLocal bool, name string) string

FSMustString is the string version of FSMustByte.

func FSString added in v0.0.5

func FSString(useLocal bool, name string) (string, error)

FSString is the string version of FSByte.

func Index

func Index(w http.ResponseWriter, r *http.Request)

func JSON

func JSON(h func(io.Reader, url.Values, httprouter.Params) (interface{}, error)) httprouter.Handle

func ListenAndServe

func ListenAndServe(stateFile, addr string, devMode bool) error

Types

type Playlist

type Playlist []SongID

type PlaylistChange added in v0.0.7

type PlaylistChange [][]string

type PlaylistInfo

type PlaylistInfo []listItem

type ProtocolData added in v0.0.7

type ProtocolData struct {
	Protocol string
	Key      string
}

type Seek added in v0.0.2

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

func NewSeek added in v0.0.2

func NewSeek(canSeek bool, sr time.Duration, f func(int) ([]float32, error)) *Seek

func (*Seek) Pos added in v0.0.2

func (s *Seek) Pos() time.Duration

func (*Seek) Read added in v0.0.2

func (s *Seek) Read(n int) (b []float32, err error)

func (*Seek) Seek added in v0.0.2

func (s *Seek) Seek(offset time.Duration) error

Seek sets the offset for the next Read to offset, relative to the origin of the file.

type Server

type Server struct {
	Queue     Playlist
	Playlists map[string]Playlist

	Repeat      bool
	Random      bool
	Protocols   map[string]map[string]protocol.Instance
	MinDuration time.Duration

	// Current song data.
	PlaylistIndex int
	// contains filtered or unexported fields
}

func New

func New(stateFile string) (*Server, error)

func (*Server) Cmd

func (srv *Server) Cmd(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) Data

func (srv *Server) Data(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) GetInstance

func (srv *Server) GetInstance(name, key string) (protocol.Instance, error)

func (*Server) GetMux

func (srv *Server) GetMux(devMode bool) *http.ServeMux

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe(addr string, devMode bool) error

ListenAndServe listens on the TCP network address addr and then calls Serve to handle requests on incoming connections.

func (*Server) OAuth

func (srv *Server) OAuth(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Server) PlaylistChange

func (srv *Server) PlaylistChange(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) ProtocolAdd

func (srv *Server) ProtocolAdd(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) ProtocolRefresh

func (srv *Server) ProtocolRefresh(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) ProtocolRemove

func (srv *Server) ProtocolRemove(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) QueueChange

func (srv *Server) QueueChange(body io.Reader, form url.Values, ps httprouter.Params) (interface{}, error)

func (*Server) WebSocket

func (srv *Server) WebSocket(ws *websocket.Conn)

type SongID

type SongID codec.ID

func (SongID) ID

func (s SongID) ID() codec.ID

func (SongID) Key

func (s SongID) Key() string

func (SongID) MarshalJSON

func (s SongID) MarshalJSON() ([]byte, error)

func (SongID) Protocol

func (s SongID) Protocol() string

type State

type State int

func (State) String

func (s State) String() string

type Status

type Status struct {
	// Playback state
	State State
	// Song ID.
	Song     SongID
	SongInfo codec.SongInfo
	// Elapsed time of current song.
	Elapsed time.Duration
	// Duration of current song.
	Time   time.Duration
	Random bool
	Repeat bool
}

Jump to

Keyboard shortcuts

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