Add Broker Info command client-side
This commit is contained in:
@@ -79,7 +79,23 @@ namespace PlantBox.Broker
|
||||
|
||||
protected override void InfoCommand(CommandStream commandStream, CommandPacket packet)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
InfoRequest infoRequest = new InfoRequest().Deserialize(packet.Arguments);
|
||||
ulong id = packet.ID;
|
||||
PlantBox plantBox = Broker.PlantBoxesManager[id];
|
||||
|
||||
if (plantBox == null)
|
||||
{
|
||||
throw new InvalidOperationException($"This PlantBox (${id}) does not exist");
|
||||
}
|
||||
|
||||
var response = new InfoResponse
|
||||
(
|
||||
plantBox.Name, plantBox.Type, plantBox.State,
|
||||
plantBox.Humidity.Min, plantBox.Humidity.Max,
|
||||
plantBox.Luminosity.Min, plantBox.Luminosity.Max,
|
||||
plantBox.Temperature.Min, plantBox.Temperature.Max
|
||||
);
|
||||
commandStream.Send(response.ToCommandPacket(id));
|
||||
}
|
||||
|
||||
protected override void PingCommand(CommandStream commandStream, CommandPacket packet)
|
||||
|
||||
Reference in New Issue
Block a user