mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
Improvements w.r.t. issue #37
This commit is contained in:
parent
72308d38d5
commit
1ec5b0e955
@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
@ -94,9 +95,17 @@ namespace Capnp.Net.Runtime.Tests
|
||||
public void ScatteredTransfer()
|
||||
{
|
||||
|
||||
using (var server = SetupServer())
|
||||
using (var server = new TcpRpcServer(IPAddress.Any, TcpPort))
|
||||
using (var client = new TcpRpcClient())
|
||||
{
|
||||
server.OnConnectionChanged += (_, e) =>
|
||||
{
|
||||
if (e.Connection.State == ConnectionState.Initializing)
|
||||
{
|
||||
e.Connection.InjectMidlayer(s => new ScatteringStream(s, 7));
|
||||
}
|
||||
};
|
||||
|
||||
client.InjectMidlayer(s => new ScatteringStream(s, 10));
|
||||
client.Connect("localhost", TcpPort);
|
||||
client.WhenConnected.Wait();
|
||||
|
@ -110,13 +110,14 @@ namespace Capnp
|
||||
#else
|
||||
var buffer = MemoryMarshal.Cast<ulong, byte>(buffers[i].Span);
|
||||
|
||||
while (buffer.Length > 0)
|
||||
do
|
||||
{
|
||||
int obtained = reader.Read(buffer);
|
||||
if (obtained == 0)
|
||||
throw StreamClosed();
|
||||
buffer = buffer.Slice(obtained);
|
||||
}
|
||||
while (buffer.Length > 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,13 @@ namespace Capnp.Rpc
|
||||
/// <exception cref="InvalidOperationException">Connection is not in state 'Initializing'</exception>
|
||||
void AttachTracer(IFrameTracer tracer);
|
||||
|
||||
/// <summary>
|
||||
/// Installs a midlayer. A midlayer is a protocal layer that resides somewhere between capnp serialization and the raw TCP stream.
|
||||
/// Thus, we have a hook mechanism for transforming data before it is sent to the TCP connection or after it was received
|
||||
/// by the TCP connection, respectively. This mechanism may be used for integrating various (de-)compression algorithms.
|
||||
/// </summary>
|
||||
/// <param name="createFunc">Callback for wrapping the midlayer around its underlying stream</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="createFunc"/> is null</exception>
|
||||
void InjectMidlayer(Func<Stream, Stream> createFunc);
|
||||
|
||||
/// <summary>
|
||||
|
@ -222,6 +222,13 @@ namespace Capnp.Rpc
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs a midlayer. A midlayer is a protocal layer that resides somewhere between capnp serialization and the raw TCP stream.
|
||||
/// Thus, we have a hook mechanism for transforming data before it is sent to the TCP connection or after it was received
|
||||
/// by the TCP connection, respectively. This mechanism may be used for integrating various (de-)compression algorithms.
|
||||
/// </summary>
|
||||
/// <param name="createFunc">Callback for wrapping the midlayer around its underlying stream</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="createFunc"/> is null</exception>
|
||||
public void InjectMidlayer(Func<Stream, Stream> createFunc)
|
||||
{
|
||||
if (createFunc == null)
|
||||
|
@ -128,6 +128,13 @@ namespace Capnp.Rpc
|
||||
Pump.AttachTracer(tracer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs a midlayer. A midlayer is a protocal layer that resides somewhere between capnp serialization and the raw TCP stream.
|
||||
/// Thus, we have a hook mechanism for transforming data before it is sent to the TCP connection or after it was received
|
||||
/// by the TCP connection, respectively. This mechanism may be used for integrating various (de-)compression algorithms.
|
||||
/// </summary>
|
||||
/// <param name="createFunc">Callback for wrapping the midlayer around its underlying stream</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="createFunc"/> is null</exception>
|
||||
public void InjectMidlayer(Func<Stream, Stream> createFunc)
|
||||
{
|
||||
if (createFunc == null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user