Closed ezio-melotti closed 2 years ago
The last 2 commits:
hab-info
and sensor-info
events to be sent. These assume that full info are sent every time, and they override the previous info.send-step-data
event. Now the client only needs to send a register-client
and the server will, in order, send hab-info
, sensor-info
, and step-batch
in a loop.See also #22 for a description of the events.
This PR does two things:
With this changes, the server asks the sensors to send a reading every second, the sensors use the
send-reading
event to emit readings, the server receives them and stores them in theSENSOR_READINGS
object. The server also keeps track ofSUBSCRIBERS
andSENSORS
and adds a main loop that is launched when the server starts. The main loop checks if there are subscribers and sensors, and if there are, it takes fromSENSOR_READINGS
the latest readings from all the sensors and creates a bundle that includes a number, a timestamp, and an object that maps each sensor with its reading. This bundle is then broadcasted to all the subscribers. The server also keeps track of sensor and subscriber (dis)connections.See also #12.