2.4.0 (2024-07-06)
Features
- ✨ add channels to followers (d86bc58)
// Start a channel that sends event, when object in 'fleet'
// enters the area of a 500m radius around
// latitude 33.5123 and longitude -112.2693 with the Leader
await tile38
.setChan('warehouse')
.nearby('fleet')
.point(33.5123, -112.2693, 500)
.exec();
Now add a receiving channel and add an event handler.
// also as of tile38 v1.33.1 followers can open a channel
const followerChannel = await tile38.follower().channel();
followerChannel.on('message', (message) => console.log(message));
Now that channel can:
// also as of tile38 v1.33.1 followers can open a channel
await followerChannel.subscribe('warehouse');
// or pattern subscribed to
await followerChannel.pSubscribe('ware*');
Every .set()
on the leader results in the geofence event
being forwarded to the follower channel.
await tile38.set('fleet', 'bus').point(33.5123001, -112.2693001).exec();
// event =
> {
"command": "set",
"group": "5c5203ccf5ec4e4f349fd038",
"detect": "inside",
"hook": "warehouse",
"key": "fleet",
"time": "2021-03-22T13:06:36.769273-07:00",
"id": "bus",
"meta": {},
"object": { "type": "Point", "coordinates": [-112.2693001, 33.5123001] }
}
// to unsubscribed
await followerChannel.unsubscribe();
// to delete with the leader
await tile38.delChan('warehouse');
// or pattern delete with the leader
await tile38.pDelChan('ware*');