Repository navigation
Expand file tree
/
Copy pathnotifier.go
More file actions
58 lines (44 loc) · 1.42 KB
/
Copy pathnotifier.go
File metadata and controls
58 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2019 Vincent Chueng (coolingfall@gmail.com).
package aria2go
import (
"log"
)
// Type definition for notifier which can be used in aria2c json rpc notification.
type Notifier interface {
// OnStart will be invoked when aria2 started to download
OnStart(gid string)
// OnPause will be invoked when aria2 paused one download
OnPause(gid string)
// OnPause will be invoked when aria2 stopped one download
OnStop(gid string)
// OnComplete will be invoked when download completed
OnComplete(gid string)
// OnError will be invoked when an error occoured
OnError(gid string)
}
// Type definition for default notifier which dose nothing.
type DefaultNotifier struct{}
// newDefaultNotifier creates a new instance of default Notifier.
func newDefaultNotifier() Notifier {
return DefaultNotifier{}
}
// OnStart implements Notifier interface.
func (n DefaultNotifier) OnStart(gid string) {
log.Printf("on start %v", gid)
}
// OnPause implements Notifier interface.
func (n DefaultNotifier) OnPause(gid string) {
log.Printf("on pause: %v", gid)
}
// OnPause implements Notifier interface.
func (n DefaultNotifier) OnStop(gid string) {
log.Printf("on stop: %v", gid)
}
// OnComplete implements Notifier interface.
func (n DefaultNotifier) OnComplete(gid string) {
log.Printf("on complete: %v", gid)
}
// OnError implements Notifier interface.
func (n DefaultNotifier) OnError(gid string) {
log.Printf("on error: %v", gid)
}