Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues when the response from the pipe is larger than the buffer size #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
16 changes: 13 additions & 3 deletions src/SoundpadConnector/Soundpad.cs
Original file line number Diff line number Diff line change
@@ -116,9 +116,19 @@ public void Disconnect() {
await _pipe.WriteAsync(buffer, 0, buffer.Length);

var responseBuffer = new byte[_pipe.OutBufferSize];
await _pipe.ReadAsync(responseBuffer, 0, responseBuffer.Length);

var responseText = Encoding.UTF8.GetString(responseBuffer).TrimEnd('\0');
var fullResponse = new byte[0];
var readBytes = 0;
do
{
readBytes = await _pipe.ReadAsync(responseBuffer, 0, responseBuffer.Length);
if (readBytes > 0)
{
Array.Resize(ref fullResponse, fullResponse.Length + readBytes);
Array.Copy(responseBuffer, 0, fullResponse, fullResponse.Length - readBytes, readBytes);
}
} while (readBytes > 0);

var responseText = Encoding.UTF8.GetString(fullResponse).TrimEnd('\0');

var response = new TResponse();
response.Parse(responseText);
2 changes: 2 additions & 0 deletions src/SoundpadConnector/SoundpadConnector.csproj
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
<PackageProjectUrl>https://github.com/medokin/soundpad-connector</PackageProjectUrl>
<Authors>Nikodem Jaworski</Authors>
<PackageTags>sdk,soundpad,pipe,ipc</PackageTags>
<AssemblyVersion>1.4.1</AssemblyVersion>
<Version>1.4.1</Version>
</PropertyGroup>

<ItemGroup>