Modify protocol according to doc

This commit is contained in:
2019-04-29 22:21:45 +02:00
parent e47f9ef5b7
commit 1072853fa5

View File

@@ -41,7 +41,7 @@ namespace PlantBox.Shared.Communication
byte[] buffer = new byte[4];
_stream.Read(buffer, 0, buffer.Length);
int length = BitConverter.ToInt32(buffer, 0);
uint length = BitConverter.ToUInt32(buffer, 0);
// Data
buffer = new byte[length];
@@ -79,7 +79,7 @@ namespace PlantBox.Shared.Communication
byte[] buffer = new byte[4];
await _stream.ReadAsync(buffer, 0, buffer.Length);
int length = BitConverter.ToInt32(buffer, 0);
uint length = BitConverter.ToUInt32(buffer, 0);
// Data
buffer = new byte[length];
@@ -116,7 +116,7 @@ namespace PlantBox.Shared.Communication
string packet = command.ToString();
byte[] data = Encoding.UTF8.GetBytes(packet);
_stream.Write(BitConverter.GetBytes(data.Length), 0, 4);
_stream.Write(BitConverter.GetBytes((uint)data.Length), 0, 4);
_stream.Write(data, 0, data.Length);
}
@@ -130,7 +130,7 @@ namespace PlantBox.Shared.Communication
string packet = command.ToString();
byte[] data = Encoding.UTF8.GetBytes(packet);
await _stream.WriteAsync(BitConverter.GetBytes(data.Length), 0, 4);
await _stream.WriteAsync(BitConverter.GetBytes((uint)data.Length), 0, 4);
await _stream.WriteAsync(data, 0, data.Length);
}
}