Skip to content

Commit 264f1ce

Browse files
committed
Added discovery id in discovery.Event struct
1 parent 3dd26d6 commit 264f1ce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arduino/discovery/discovery.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ func (p *Port) String() string {
121121

122122
// Event is a pluggable discovery event
123123
type Event struct {
124-
Type string
125-
Port *Port
124+
Type string
125+
Port *Port
126+
DiscoveryID string
126127
}
127128

128129
// New create and connect to the given pluggable discovery
@@ -178,7 +179,7 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
178179
disc.statusMutex.Lock()
179180
disc.cachedPorts[msg.Port.Address+"|"+msg.Port.Protocol] = msg.Port
180181
if disc.eventChan != nil {
181-
disc.eventChan <- &Event{"add", msg.Port}
182+
disc.eventChan <- &Event{"add", msg.Port, disc.GetID()}
182183
}
183184
disc.statusMutex.Unlock()
184185
} else if msg.EventType == "remove" {
@@ -189,7 +190,7 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
189190
disc.statusMutex.Lock()
190191
delete(disc.cachedPorts, msg.Port.Address+"|"+msg.Port.Protocol)
191192
if disc.eventChan != nil {
192-
disc.eventChan <- &Event{"remove", msg.Port}
193+
disc.eventChan <- &Event{"remove", msg.Port, disc.GetID()}
193194
}
194195
disc.statusMutex.Unlock()
195196
} else {

0 commit comments

Comments
 (0)