server

package
Version: v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRawStream added in v1.0.0

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

GetRawStream returns a decoded stream from a common.Stream

Types

type Config added in v0.3.0

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

Config contains Server's configuration

type RequestHandler added in v0.7.5

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

RequestHandler is a function that handles a request from user.

type Response added in v0.6.0

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 added in v0.6.0

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 added in v0.7.5

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

AddMessageHandler registers a new message handler for the specified opcode

func (*Server) Close added in v1.0.0

func (s *Server) Close() error

func (*Server) HandleError added in v0.6.0

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

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

func (*Server) RemoveMessageHandler added in v0.7.5

func (s *Server) RemoveMessageHandler(opcode int)

RemoveMessageHandler unregisters the specified opcode

func (*Server) Shutdown added in v1.0.0

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

func (*Server) Start added in v0.4.0

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

Start starts the server, listening at addr

func (*Server) StartWithTLS added in v0.4.0

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

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

Jump to

Keyboard shortcuts

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