To realise the use case "Detect and Locate", this sample application consumes "Device Location Update" Event of the Cisco Spaces Firehose API. This can be used as a starting point and reference for consuming the Cisco Spaces Firehose API events.
Sample Application consists of the below components
The API Server consumes "DEVICE_LOCATION_UPDATE" event and keeps updating RocksDB or Redis Cache (based on which one is enabled, by default uses RocksDB) for each Device MAC address. Server also exposes an HTTP GET API which can be invoked with a MAC address param(mac), to get recent location update for the given mac.
API server also writes every event into given corresponding Kafka topic(only if Kafka configuration is enabled) which can be used by a Kafka client for further processing.
NOTE: Regarding RocksDB & Redis Cache, enable any one of them, in case of both are enabled then RocksDB will be considered for pulling data for the HTTP GET API.
api.key={{Firehose API Key}} api.url={{Firehose API URL}} http.port={{http server port}} redis.feeder.enabled=false rocksdb.feeder.enabled=true
mvn install
.com.cisco.dnaspaces.APIConsumer
class to run the application.Proxy Server is used to avoid CORS restriction while using the partners api for retrieving map information and image from client application. This takes the request and communicates with API and serves response to client application without any CORS Restriction
apiserver.host={{Partners API Host}} apiserver.apikey={{Partners API Key}}
npm install
node server
The client application provides an UI to enter MAC address of client and when user clicks on "start polling", Ajax polling starts with a certain time interval to server. On each location update, co-ordinates are stacked to the screen.
{ "apiUrl":"{{API Server url}}", "serverUrl":"{{Proxy Server url}}" }
ng serve
This is a standalone sample application which subscribes to the provided Kafka Topic into which API server pushes the event data. Kafka Consumer Application subscribes to given Kafka Topic and writes every received events to console.
com.cisco.dnaspaces.clients.kafka.Application
class to run the application.Once all the applications are started,
Owner
Contributors
Categories
Products
Cisco SpacesProgramming Languages
TypeScriptJavaLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community