package rpc12import (3log "github.com/sirupsen/logrus"4)56type Event struct {7Gid string `json:"gid"` // GID of the download8}910// The RPC server might send notifications to the client.11// Notifications is unidirectional, therefore the client which receives the notification must not respond to it.12// The method signature of a notification is much like a normal method request but lacks the id key1314type websocketResponse struct {15clientResponse16Method string `json:"method"`17Params []Event `json:"params"`18}1920// Notifier handles rpc notification from aria2 server21type Notifier interface {22// OnDownloadStart will be sent when a download is started.23OnDownloadStart([]Event)24// OnDownloadPause will be sent when a download is paused.25OnDownloadPause([]Event)26// OnDownloadStop will be sent when a download is stopped by the user.27OnDownloadStop([]Event)28// OnDownloadComplete will be sent when a download is complete. For BitTorrent downloads, this notification is sent when the download is complete and seeding is over.29OnDownloadComplete([]Event)30// OnDownloadError will be sent when a download is stopped due to an error.31OnDownloadError([]Event)32// OnBtDownloadComplete will be sent when a torrent download is complete but seeding is still going on.33OnBtDownloadComplete([]Event)34}3536type DummyNotifier struct{}3738func (DummyNotifier) OnDownloadStart(events []Event) { log.Printf("%s started.", events) }39func (DummyNotifier) OnDownloadPause(events []Event) { log.Printf("%s paused.", events) }40func (DummyNotifier) OnDownloadStop(events []Event) { log.Printf("%s stopped.", events) }41func (DummyNotifier) OnDownloadComplete(events []Event) { log.Printf("%s completed.", events) }42func (DummyNotifier) OnDownloadError(events []Event) { log.Printf("%s error.", events) }43func (DummyNotifier) OnBtDownloadComplete(events []Event) { log.Printf("bt %s completed.", events) }444546