Documentation ¶
Overview ¶
Package protocol implements the protocol decoding, encoding of the go.touhou.fm/radio/server players
Messages ¶
The protocol consists of several messages that are sent between the different services:
Basic:
Want sent from the player to request new songs Skip sent from a controller to skip a song Status sent from a controller to ask for current status Quit sent from a controller to stop the service gracefully
Loading:
Next sent from a controller to load a song Loaded sent from the player to indicate the song has been loaded Playing sent from the server to indicate the song has begun playing Stopped sent from the server to indicate the song has stopped playing
Meta:
Meta sent from a controller to update the metadata broadcast by the player
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrInvalidType is returned when a message is not understood
Functions ¶
This section is empty.
Types ¶
type Loaded ¶
type Loaded struct { // The deck number the song has been loaded in Deck int // The song that has been loaded Song }
Loaded describes a message that indicates a song has been loaded
The player will send this message to indicate to a controller that the song has been loaded. This will be sent regardless of whether it can play it. If the song cannot be played, the player will send a Want message as soon as it fails to load it.
Sending Status will also yield Loaded messages, 1 for each deck
type Message ¶
Message is the interface that wraps the Encode method.
Encode serializes the message to a json string.
type Meta ¶
Meta describes a message that indiates the metadata to broadcast to the listeners.
A controller can send this to provide additional information about the currently playing song like title, artist, circle, album, year, etc.
type Next ¶
type Next struct { // The Song to enqueue Song }
Next describes a message that indicates to a player what song to add to the playlist
A controller should send this in response to a Want message. Depending on the targetted service, it may ignore or add this to the end of its queue. Player will ignore extra songs and Playlist will append extra songs to its playlist.
type Playing ¶
type Playing transport
Playing describes a message that indicates a deck has begun playing
The player will send this message to indicate a previously loaded song has begun playback. The position will indicate the current position relative to the start at the time this message has been written
Sending Status will also yield Playing messages, 1 for each deck. Its Position value will in this case refers to the actual playback position at the time of reception of the Status message.
type Quit ¶
type Quit struct{}
Quit describes a message that requests the receiver to stop
A controller can send this to any service to cause it to stop its processing and gracefully exit
type Skip ¶
type Skip struct{}
Skip describes a message that requests a song to be skipped
A controller can send this to a player to cause the player to immediately switch to the next song
type Song ¶
type Song struct { // The relative path to the file File string // The starting position of the song in samples Start int64 // The ending position of the song in samples Stop int64 }
Song stores the necessary information to identify a song for playback.
type Status ¶
type Status struct{}
Status describes a message that requests the current status from the player
A controller can send this to a player to cause the player to resend its Loaded/Playing/Stopped messages.
type Stopped ¶
type Stopped transport
Stopped describes a message that incidates a deck has stopped playing.
The player will send this message to indicate a previously loaded song has stopped playback. The position will indicate the current position relative to the start at the time this message has been written
Sending Status will also yield Stopped messages, 1 for each deck. Its Position value in this case refers to the actual playback position at the time of reception of the Status message.
type Want ¶
type Want struct{}
Want describes a message that requests a new song to be given
A player or playlist will send a Want message when it has no more items to play
Directories ¶
Path | Synopsis |
---|---|
Package channels provides the Producer, Consumer and Channels interfaces to be used for connecting producers and consumers together.
|
Package channels provides the Producer, Consumer and Channels interfaces to be used for connecting producers and consumers together. |
Package consumer contains the Consumer protocol handler.
|
Package consumer contains the Consumer protocol handler. |
Package producer contains the Producer protocol handler.
|
Package producer contains the Producer protocol handler. |
Package util provides various utilities for the protocol
|
Package util provides various utilities for the protocol |