Documentation
¶
Index ¶
- Constants
- Variables
- func ConnectWebSocket(url string, headers http.Header) (*websocket.Conn, *http.Response, error)
- func Error(message string)
- func Errorf(format string, v ...interface{})
- func FromJSON(data string, v interface{}) error
- func HandleError(err error)
- func Info(message string)
- func Infof(format string, v ...interface{})
- func MakeHTTPRequest(method, url string, headers map[string]string, body interface{}) (*http.Response, error)
- func NewLavalinkError(code int, message string) error
- func ReadWebSocketMessage(conn *websocket.Conn) (messageType int, message []byte, err error)
- func Retry(attempts int, sleep time.Duration, fn func() error) error
- func ToJSON(v interface{}) (string, error)
- func WriteWebSocketMessage(conn *websocket.Conn, messageType int, message []byte) error
- type LavalinkError
Constants ¶
View Source
const ( LavalinkWebSocketEndpoint = "/websocket" LavalinkRestEndpoint = "/v3/players" )
API Endpoints
View Source
const ( EventTypeTrackStart = "TrackStartEvent" EventTypeTrackEnd = "TrackEndEvent" EventTypeTrackException = "TrackExceptionEvent" EventTypeTrackStuck = "TrackStuckEvent" EventTypeWebSocketClosed = "WebSocketClosedEvent" )
Event Types
View Source
const ( DefaultReconnectDelay = 5 // seconds DefaultBufferSize = 4096 DefaultVolume = 100 )
Default Values
View Source
const ( ProtocolVersion = "1.0" UserAgent = "liblavalink.go" )
Other Constants
Variables ¶
View Source
var ( ErrNodeConnectionFailed = &LavalinkError{Code: 1001, Message: "Failed to connect to Lavalink node"} ErrWebSocketClosed = &LavalinkError{Code: 1002, Message: "WebSocket connection closed unexpectedly"} ErrTrackNotFound = &LavalinkError{Code: 1003, Message: "Track not found"} ErrInvalidRequest = &LavalinkError{Code: 1004, Message: "Invalid request"} ErrPlaybackFailed = &LavalinkError{Code: 1005, Message: "Playback failed"} )
Functions ¶
func ConnectWebSocket ¶
WebSocket utility functions
func HandleError ¶
func HandleError(err error)
func MakeHTTPRequest ¶
func MakeHTTPRequest(method, url string, headers map[string]string, body interface{}) (*http.Response, error)
MakeHTTPRequest makes an HTTP request with the specified method, URL, headers, and body.
func NewLavalinkError ¶
Error handling functions
func ReadWebSocketMessage ¶
Types ¶
type LavalinkError ¶
Custom error types
func (*LavalinkError) Error ¶
func (e *LavalinkError) Error() string
Click to show internal directories.
Click to hide internal directories.