Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRawStream

func GetRawStream(s common.Stream) (stream io.ReadCloser, err error)

GetRawStream returns a decoded stream from a common.Stream

Types

type Config

type Config struct {
	MusixMatchUserToken   string
	MusixMatchOBUserToken string
	Plugins               []*plugin.Plugin
	RadioEnabled          bool
	StaticFilesPath       string
}

Config contains Server's configuration

type RequestHandler

type RequestHandler func(s *Server, msg wsMessage) Response

RequestHandler is a function that handles a request from user.

type Response

type Response struct {
	Operation int                    `json:"op"`
	Success   bool                   `json:"success"`
	Reason    string                 `json:"reason"`
	Data      map[string]interface{} `json:"data"`
	Nonce     int                    `json:"nonce"`
}

Response will be encode in JSON and send to user

func (Response) EncodeJSON

func (r Response) EncodeJSON() []byte

EncodeJSON encodes Response to JSON

type Server

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

Server is a MusicStream server

func NewServer

func NewServer(config Config) *Server

NewServer returns a new server

func (*Server) AddMessageHandler

func (s *Server) AddMessageHandler(opcode int, handler RequestHandler)

AddMessageHandler registers a new message handler for the specified opcode

func (*Server) Close

func (s *Server) Close() error

func (*Server) HandleError

func (s *Server) HandleError(err error, c echo.Context)

HandleError defines an error handler that complies with echo's standards.

func (*Server) RemoveMessageHandler

func (s *Server) RemoveMessageHandler(opcode int)

RemoveMessageHandler unregisters the specified opcode

func (*Server) Shutdown

func (s *Server) Shutdown(context context.Context) (err error)

func (*Server) Start

func (s *Server) Start(addr string) (err error)

Start starts the server, listening at addr

func (*Server) StartWithTLS

func (s *Server) StartWithTLS(addr string) (err error)

StartWithTLS starts the server, listening at addr, also tries to get a cert from LetsEncrypt