-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathevents.go
More file actions
77 lines (58 loc) · 1.69 KB
/
events.go
File metadata and controls
77 lines (58 loc) · 1.69 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package gomavlib
import (
"github.com/bluenviron/gomavlib/v4/pkg/frame"
"github.com/bluenviron/gomavlib/v4/pkg/message"
)
// Event is the interface implemented by all events received with node.Events().
type Event interface {
isEventOut()
}
// EventChannelOpen is fired when a channel is opened.
type EventChannelOpen struct {
Channel *Channel
}
func (*EventChannelOpen) isEventOut() {}
// EventChannelClose is fired when a channel is closed.
type EventChannelClose struct {
Channel *Channel
Error error
}
func (*EventChannelClose) isEventOut() {}
// EventFrame is fired when a frame is received.
type EventFrame struct {
// frame
Frame frame.Frame
// 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 fired when a parse error occurs.
type EventParseError struct {
// error
Error error
// channel used to send the frame
Channel *Channel
}
func (*EventParseError) isEventOut() {}
// EventStreamRequested is fired when an automatic stream request is sent.
type EventStreamRequested struct {
// channel to which the stream request is addressed
Channel *Channel
// system id to which the stream requests is addressed
SystemID byte
// component id to which the stream requests is addressed
ComponentID byte
}
func (*EventStreamRequested) isEventOut() {}