-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathevents.go
74 lines (57 loc) · 1.76 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package gomavlib
import (
"github.com/bluenviron/gomavlib/v3/pkg/frame"
"github.com/bluenviron/gomavlib/v3/pkg/message"
)
// Event is the interface implemented by all events received with node.Events().
type Event interface {
isEventOut()
}
// EventChannelOpen is the event fired when a channel gets opened.
type EventChannelOpen struct {
Channel *Channel
}
func (*EventChannelOpen) isEventOut() {}
// EventChannelClose is the event fired when a channel gets closed.
type EventChannelClose struct {
Channel *Channel
}
func (*EventChannelClose) isEventOut() {}
// EventFrame is the event fired when a frame is received.
type EventFrame struct {
// the frame
Frame frame.Frame
// the channel from which the frame was received
Channel *Channel
}
func (*EventFrame) isEventOut() {}
// SystemID returns the frame system id.
func (res *EventFrame) SystemID() byte {
return res.Frame.GetSystemID()
}
// ComponentID returns the frame component id.
func (res *EventFrame) ComponentID() byte {
return res.Frame.GetComponentID()
}
// Message returns the message inside the frame.
func (res *EventFrame) Message() message.Message {
return res.Frame.GetMessage()
}
// EventParseError is the event fired when a parse error occurs.
type EventParseError struct {
// the error
Error error
// the channel used to send the frame
Channel *Channel
}
func (*EventParseError) isEventOut() {}
// EventStreamRequested is the event fired when an automatic stream request is sent.
type EventStreamRequested struct {
// the channel to which the stream request is addressed
Channel *Channel
// the system id to which the stream requests is addressed
SystemID byte
// the component id to which the stream requests is addressed
ComponentID byte
}
func (*EventStreamRequested) isEventOut() {}