using Capnp.FrameTracing; using System; using System.IO; namespace Capnp.Rpc { /// /// Models an RPC connection. /// public interface IConnection { /// /// Returns the state of this connection. /// ConnectionState State { get; } /// /// TCP port (local end), or null if the connection is not yet established. /// int? LocalPort { get; } /// /// TCP port (remote end), or null if the connection is not yet established. /// int? RemotePort { get; } /// /// Receive message counter /// long RecvCount { get; } /// /// Sent message counter /// long SendCount { get; } /// /// Whether the RPC engine is currently computing. /// bool IsComputing { get; } /// /// Whether the connection is idle, waiting for data to receive. /// bool IsWaitingForData { get; } /// /// Attaches a tracer to this connection. Only allowed in state 'Initializing'. /// /// Tracer to attach /// is null /// Connection is not in state 'Initializing' void AttachTracer(IFrameTracer tracer); /// /// 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. /// /// Callback for wrapping the midlayer around its underlying stream /// is null void InjectMidlayer(Func createFunc); /// /// Prematurely closes this connection. Note that there is usually no need to close a connection manually. The typical use case /// of this method is to refuse an incoming connection in the TcpRpcServer.OnConnectionChanged callback. /// void Close(); } }