v1

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUBSCRIBE = "subscribe"
	SEND      = "send"
	LEAVE     = "leave"
	SHUTDOWN  = "shutdown"
	INIT      = "init"
)
View Source
const (
	EventTime       = "time"
	EventMetadata   = "metadata"
	EventListeners  = "listeners"
	EventStreamer   = "streamer"
	EventQueue      = "queue"
	EventLastPlayed = "lastplayed"
	EventThread     = "thread"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Context   context.Context
	Config    config.Config
	Search    radio.SearchService
	Templates templates.Executor
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(ctx context.Context, cfg config.Config,
	templates templates.Executor,
	fs afero.Fs,
	songSecret secret.Secret) (*API, error)

func (*API) GetSong

func (a *API) GetSong(w http.ResponseWriter, r *http.Request)

func (*API) Route

func (a *API) Route(r chi.Router)

func (*API) SearchHTML

func (a *API) SearchHTML(w http.ResponseWriter, r *http.Request)

type EventName

type EventName = string

type LastPlayed

type LastPlayed []radio.Song

func (LastPlayed) TemplateBundle

func (LastPlayed) TemplateBundle() string

func (LastPlayed) TemplateName

func (LastPlayed) TemplateName() string

type Listeners

type Listeners radio.Listeners

func (Listeners) TemplateBundle

func (Listeners) TemplateBundle() string

func (Listeners) TemplateName

func (Listeners) TemplateName() string

type NowPlaying

type NowPlaying radio.Status

func (NowPlaying) TemplateBundle

func (NowPlaying) TemplateBundle() string

func (NowPlaying) TemplateName

func (NowPlaying) TemplateName() string

type Queue

type Queue []radio.QueueEntry

func (Queue) TemplateBundle

func (Queue) TemplateBundle() string

func (Queue) TemplateName

func (Queue) TemplateName() string

type SearchInput

type SearchInput struct {
	Result *radio.SearchResult
}

func (SearchInput) TemplateBundle

func (SearchInput) TemplateBundle() string

func (SearchInput) TemplateName

func (SearchInput) TemplateName() string

type Stream

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

func NewStream

func NewStream(exec templates.Executor) *Stream

func (*Stream) NewMessage

func (s *Stream) NewMessage(event EventName, data templates.TemplateSelectable) message

func (*Stream) SendEvent

func (s *Stream) SendEvent(event EventName, m message)

SendEvent sends an SSE event with the data given.

func (*Stream) SendLastPlayed

func (s *Stream) SendLastPlayed(data []radio.Song)

func (*Stream) SendListeners

func (s *Stream) SendListeners(data radio.Listeners)

func (*Stream) SendNowPlaying

func (s *Stream) SendNowPlaying(data radio.Status)

func (*Stream) SendQueue

func (s *Stream) SendQueue(data []radio.QueueEntry)

func (*Stream) SendStreamer

func (s *Stream) SendStreamer(data radio.User)

func (*Stream) ServeHTTP

func (s *Stream) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler where each client gets send all SSE events that occur after connecting. There is no history.

func (*Stream) Shutdown

func (s *Stream) Shutdown()

Shutdown disconnects all connected clients

type Streamer

type Streamer radio.User

func (Streamer) TemplateBundle

func (Streamer) TemplateBundle() string

func (Streamer) TemplateName

func (Streamer) TemplateName() string

Jump to

Keyboard shortcuts

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