2 Star 0 Fork 0

TeamsHub/backend-gopkg

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
notification.go 1.84 KB
Copy Edit Raw Blame History
HCY authored 2024-05-10 12:41 +08:00 . c
package rpc
import (
"log"
)
type Event struct {
Gid string `json:"gid"` // GID of the download
}
// The RPC server might send notifications to the client.
// Notifications is unidirectional, therefore the client which receives the notification must not respond to it.
// The method signature of a notification is much like a normal method request but lacks the id key
type websocketResponse struct {
clientResponse
Method string `json:"method"`
Params []Event `json:"params"`
}
// Notifier handles rpc notification from aria2 server
type Notifier interface {
// OnDownloadStart will be sent when a download is started.
OnDownloadStart([]Event)
// OnDownloadPause will be sent when a download is paused.
OnDownloadPause([]Event)
// OnDownloadStop will be sent when a download is stopped by the user.
OnDownloadStop([]Event)
// 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.
OnDownloadComplete([]Event)
// OnDownloadError will be sent when a download is stopped due to an error.
OnDownloadError([]Event)
// OnBtDownloadComplete will be sent when a torrent download is complete but seeding is still going on.
OnBtDownloadComplete([]Event)
}
type DummyNotifier struct{}
func (DummyNotifier) OnDownloadStart(events []Event) { log.Printf("%s started.", events) }
func (DummyNotifier) OnDownloadPause(events []Event) { log.Printf("%s paused.", events) }
func (DummyNotifier) OnDownloadStop(events []Event) { log.Printf("%s stopped.", events) }
func (DummyNotifier) OnDownloadComplete(events []Event) { log.Printf("%s completed.", events) }
func (DummyNotifier) OnDownloadError(events []Event) { log.Printf("%s error.", events) }
func (DummyNotifier) OnBtDownloadComplete(events []Event) { log.Printf("bt %s completed.", events) }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.5.14

Search