Documentation
Index ¶
- func GetRawStream(s common.Stream) (stream io.ReadCloser, err error)
- type Config
- type RequestHandler
- type Response
- type Server
- func (s *Server) AddMessageHandler(opcode int, handler RequestHandler)
- func (s *Server) Close() error
- func (s *Server) HandleError(err error, c echo.Context)
- func (s *Server) RemoveMessageHandler(opcode int)
- func (s *Server) Shutdown(context context.Context) (err error)
- func (s *Server) Start(addr string) (err error)
- func (s *Server) StartWithTLS(addr string) (err error)
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 ¶
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 ¶
EncodeJSON encodes Response to JSON
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a MusicStream server
func (*Server) AddMessageHandler ¶
func (s *Server) AddMessageHandler(opcode int, handler RequestHandler)
AddMessageHandler registers a new message handler for the specified opcode
func (*Server) HandleError ¶
HandleError defines an error handler that complies with echo's standards.
func (*Server) RemoveMessageHandler ¶
RemoveMessageHandler unregisters the specified opcode
func (*Server) StartWithTLS ¶
StartWithTLS starts the server, listening at addr, also tries to get a cert from LetsEncrypt