backend

package
v0.0.0-...-23f444a Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The ready status is AND'd together to get an all-ready status
	PLAYER_BUSY  = false
	PLAYER_READY = true
)
View Source
const (
	LogPrefix string = "ytb-be" // logging prefix name

)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendServer

type BackendServer struct {
	bepb.UnimplementedYtbBackendServer
	bepb.UnimplementedYtbBePlayerServer
	// contains filtered or unexported fields
}

* Implements the backend rpc server interface

func NewServer

func NewServer(addr string, loadFile string, dbPath string, ytApiKey string) *BackendServer

* Create a new yt_box backend server

func (*BackendServer) CreateRoom

func (s *BackendServer) CreateRoom(con context.Context, room *bepb.Room) (*bepb.Room, error)

* Handles command to create a new room. Room names should be unique. Will * return an error if the room already exists.

func (*BackendServer) GetNowPlaying

func (s *BackendServer) GetNowPlaying(con context.Context, empty *cmpb.Empty) (*cmpb.Song, error)

* Returns the song that should be considered "now playing". If there isn't a * current song, then an empty Song struct is returned.

func (*BackendServer) GetPlaylist

func (s *BackendServer) GetPlaylist(con context.Context, arg *cmpb.Empty) (*bepb.Playlist, error)

* Returns the songs in the queue back to the requesting client

func (*BackendServer) GetRoom

func (s *BackendServer) GetRoom(con context.Context, room *bepb.Room) (*bepb.Room, error)

* Handles querying of a room for its existence.

func (*BackendServer) LoginUser

func (s *BackendServer) LoginUser(con context.Context, user *bepb.User) (*bepb.User, error)

* Login the given user. If the userId is zero, then a new user needs to be * created. A successful call will echo the username and return a userId * greater than zero. An id of zero indicates an error occurred and the user * will not be considered to be logged in. An a user already exists with the * given id, but with a different name, then the new name shall be applied to * the database.

func (*BackendServer) NextSong

func (s *BackendServer) NextSong(con context.Context, empty *cmpb.Empty) (*bepb.Error, error)

* Forwards the command to skip the currently playing song onto the remote * player

func (*BackendServer) PauseSong

func (s *BackendServer) PauseSong(con context.Context, empty *cmpb.Empty) (*bepb.Error, error)

* Forwards the command to pause the currently playing song onto the remote * player

func (*BackendServer) PopQueue

func (s *BackendServer) PopQueue(con context.Context, empty *cmpb.Empty) (*cmpb.Song, error)

* Pops a song off the top of the queueMgr and returns it

func (*BackendServer) RemoveSong

func (s *BackendServer) RemoveSong(con context.Context, eviction *bepb.Eviction) (*bepb.Error, error)

* Removes the given song from the playlist. The user identified by the song * eviction must match the id of the user who submitted the song.

func (*BackendServer) SavePlaylist

func (s *BackendServer) SavePlaylist(con context.Context, fname *bepb.FilePath) (*bepb.Error, error)

* Saves the current playlist to the given file location

func (*BackendServer) SendSong

func (s *BackendServer) SendSong(con context.Context, sub *bepb.Submission) (*bepb.Error, error)

* Receive a song from a remote client for appending to the play queue

func (*BackendServer) Serve

func (s *BackendServer) Serve()

* Start the server

func (*BackendServer) SongPlayer

func (s *BackendServer) SongPlayer(stream bepb.YtbBePlayer_SongPlayerServer) error

* Stream RPC connection with the remote player client

func (*BackendServer) Stop

func (s *BackendServer) Stop()

* Stop the server

type SongFetcher

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

type UserCache

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

func (*UserCache) AddUserToCache

func (c *UserCache) AddUserToCache(userId uint32, username string, roomId uint32)

* Adds a username and id to the cache

func (*UserCache) Init

func (c *UserCache) Init()

* Initialize the user cache

func (*UserCache) LookupRoomId

func (c *UserCache) LookupRoomId(userId uint32) (uint32, bool)

func (*UserCache) LookupUsername

func (c *UserCache) LookupUsername(userId uint32) (string, bool)

* Find the username associated with the user id

type UserEntry

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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