-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathevents.go
52 lines (43 loc) · 1.51 KB
/
events.go
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
package iface
import (
"github.com/usnistgov/ndn-dpdk/core/events"
)
var emitter = events.NewEmitter()
const (
evtFaceNew = "FaceNew"
evtFaceUp = "FaceUp"
evtFaceDown = "FaceDown"
evtFaceClosing = "FaceClosing"
evtFaceClosed = "FaceClosed"
evtCloseAll = "CloseAll"
)
// OnFaceNew registers a callback when a new face is created.
// Return a function that cancels the callback registration.
func OnFaceNew(cb func(ID)) (cancel func()) {
return emitter.On(evtFaceNew, cb)
}
// OnFaceUp registers a callback when a face becomes UP.
// Return a function that cancels the callback registration.
func OnFaceUp(cb func(ID)) (cancel func()) {
return emitter.On(evtFaceUp, cb)
}
// OnFaceDown registers a callback when a face becomes DOWN.
// Return a function that cancels the callback registration.
func OnFaceDown(cb func(ID)) (cancel func()) {
return emitter.On(evtFaceDown, cb)
}
// OnFaceClosing registers a callback when a face is closing.
// Return a function that cancels the callback registration.
func OnFaceClosing(cb func(ID)) (cancel func()) {
return emitter.On(evtFaceClosing, cb)
}
// OnFaceClosed registers a callback when a face is closed.
// Return a function that cancels the callback registration.
func OnFaceClosed(cb func(ID)) (cancel func()) {
return emitter.On(evtFaceClosed, cb)
}
// OnCloseAll registers a callback when CloseAll() is requested.
// Return a function that cancels the callback registration.
func OnCloseAll(cb func()) (cancel func()) {
return emitter.On(evtCloseAll, cb)
}