Modify protocol according to doc
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user