diff --git a/PlantBox.Shared/Communication/CommandStream.cs b/PlantBox.Shared/Communication/CommandStream.cs
index 92b225f..4124903 100644
--- a/PlantBox.Shared/Communication/CommandStream.cs
+++ b/PlantBox.Shared/Communication/CommandStream.cs
@@ -1,4 +1,5 @@
-using System;
+using PlantBox.Shared.Communication.Commands;
+using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
@@ -48,6 +49,18 @@ namespace PlantBox.Shared.Communication
return new CommandPacket(command, packet[1].Split(';'));
}
+ ///
+ /// Read a from the stream and deserialize data to a
+ ///
+ /// A valid
+ ///
+ public (CommandPacket, T) Receive() where T : CommandSerializable, new()
+ {
+ var packet = Receive();
+
+ return (packet, new T().Deserialize(packet.Arguments));
+ }
+
///
/// Read a from the stream asynchronously
///
@@ -74,6 +87,18 @@ namespace PlantBox.Shared.Communication
return new CommandPacket(command, packet[1].Split(';'));
}
+ ///
+ /// Read a from the stream and deserialize data to a asynchronously
+ ///
+ /// A valid
+ ///
+ public async Task<(CommandPacket, T)> ReceiveAsync() where T : CommandSerializable, new()
+ {
+ var packet = await ReceiveAsync();
+
+ return (packet, new T().Deserialize(packet.Arguments));
+ }
+
///
/// Write a in the stream
///