mirror of https://github.com/tidwall/tile38.git
Allow for all command types for roaming event
Prior to this commit roaming geofences only registered changes to the SET command. Now it will work for SET/DEL/FSET, just like non-roaming geofences. To opt out of these events, explicitly choose which event you would like to register when you create the geofences. For example: NEARBY fleet FENCE COMMANDS set,del ROAM fleet * 5000 Will only fire off events from SET and DEL command. Closes #597
This commit is contained in:
parent
189de6496a
commit
b5691f7dd5
|
@ -99,9 +99,9 @@ func fenceMatch(
|
||||||
roamNearbys, roamFaraways =
|
roamNearbys, roamFaraways =
|
||||||
fenceMatchRoam(sw.s, fence, details.id,
|
fenceMatchRoam(sw.s, fence, details.id,
|
||||||
details.oldObj, details.obj)
|
details.oldObj, details.obj)
|
||||||
}
|
if len(roamNearbys) == 0 && len(roamFaraways) == 0 {
|
||||||
if len(roamNearbys) == 0 && len(roamFaraways) == 0 {
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
}
|
||||||
detect = "roam"
|
detect = "roam"
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,6 +238,12 @@ func fenceMatch(
|
||||||
case "roam":
|
case "roam":
|
||||||
if len(msgs) > 0 {
|
if len(msgs) > 0 {
|
||||||
var nmsgs []string
|
var nmsgs []string
|
||||||
|
for _, msg := range msgs {
|
||||||
|
cmd := gjson.Get(msg, "command")
|
||||||
|
if cmd.Exists() && cmd.String() != "set" {
|
||||||
|
nmsgs = append(nmsgs, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
for i := range roamNearbys {
|
for i := range roamNearbys {
|
||||||
nmsg := extendRoamMessage(sw, fence,
|
nmsg := extendRoamMessage(sw, fence,
|
||||||
"nearby", msgs[0], roamNearbys[i])
|
"nearby", msgs[0], roamNearbys[i])
|
||||||
|
|
Loading…
Reference in New Issue