< Summary

Information
Class: Ice.WSConnectionInfo
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Connection.cs
Tag: 71_18251537082
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 289
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Total methods: 1
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Connection.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3#nullable enable
 4
 5namespace Ice;
 6
 7/// <summary>
 8/// The batch compression option when flushing queued batch requests.
 9/// </summary>
 10public enum CompressBatch
 11{
 12    /// <summary>
 13    /// Compress the batch requests.
 14    /// </summary>
 15    Yes,
 16
 17    /// <summary>
 18    /// Don't compress the batch requests.
 19    /// </summary>
 20    No,
 21
 22    /// <summary>
 23    /// Compress the batch requests if at least one request was made on a compressed proxy.
 24    /// </summary>
 25    BasedOnProxy
 26}
 27
 28public delegate void CloseCallback(Connection con);
 29
 30/// <summary>
 31/// The user-level interface to a connection.
 32/// </summary>
 33public interface Connection
 34{
 35    /// <summary>
 36    /// Aborts this connection.
 37    /// </summary>
 38    void abort();
 39
 40    /// <summary>
 41    /// Closes the connection gracefully after waiting for all outstanding invocations to complete.
 42    /// </summary>
 43    /// <returns>A task that completes when the connection is closed.</returns>
 44    /// <remarks>If this operation takes longer than the configured close timeout, the connection is aborted with a
 45    /// <see cref="CloseTimeoutException"/>.</remarks>
 46    Task closeAsync();
 47
 48    /// <summary>
 49    /// Create a special proxy that always uses this connection.
 50    /// This can be used for callbacks from a server to a
 51    /// client if the server cannot directly establish a connection to the client, for example because of firewalls. In
 52    /// this case, the server would create a proxy using an already established connection from the client.
 53    /// </summary>
 54    /// <param name="id">The identity for which a proxy is to be created.</param>
 55    /// <returns>A proxy that matches the given identity and uses this connection.</returns>
 56    ObjectPrx createProxy(Identity id);
 57
 58    /// <summary>
 59    /// Associates an object adapter with this connection. When a connection receives a request, it dispatches this
 60    /// request using its associated object adapter. If the associated object adapter is null, the connection
 61    /// rejects any incoming request with an <see cref="ObjectNotExistException" />.
 62    /// The default object adapter of an incoming connection is the object adapter that created this connection;
 63    /// the default object adapter of an outgoing connection is the communicator's default object adapter.
 64    /// </summary>
 65    /// <param name="adapter">The object adapter to associate with this connection.</param>
 66    /// <seealso cref="Communicator.getDefaultObjectAdapter"/>
 67    void setAdapter(ObjectAdapter? adapter);
 68
 69    /// <summary>
 70    /// Gets the object adapter associated with this connection.
 71    /// </summary>
 72    /// <returns>The object adapter associated with this connection.</returns>
 73    ObjectAdapter? getAdapter();
 74
 75    /// <summary>
 76    /// Get the endpoint from which the connection was created.
 77    /// </summary>
 78    /// <returns>The endpoint from which the connection was created.</returns>
 79    Endpoint getEndpoint();
 80
 81    /// <summary>
 82    /// Flush any pending batch requests for this connection.
 83    /// This means all batch requests invoked on fixed proxies associated with the connection.
 84    /// </summary>
 85    /// <param name="compress">Specifies whether or not the queued batch requests should be compressed before being sent
 86    /// over the wire.</param>
 87    void flushBatchRequests(CompressBatch compress);
 88
 89    System.Threading.Tasks.Task flushBatchRequestsAsync(
 90        CompressBatch compress,
 91        System.IProgress<bool>? progress = null,
 92        System.Threading.CancellationToken cancel = default);
 93
 94    /// <summary>
 95    /// Set a close callback on the connection.
 96    /// The callback is called by the connection when it's closed. The callback
 97    /// is called from the Ice thread pool associated with the connection. If the callback needs more information about
 98    /// the closure, it can call Connection.throwException.
 99    /// </summary>
 100    /// <param name="callback">The close callback object.</param>
 101    void setCloseCallback(CloseCallback callback);
 102
 103    /// <summary>
 104    /// Disables the inactivity check on this connection.
 105    /// </summary>
 106    void disableInactivityCheck();
 107
 108    /// <summary>
 109    /// Return the connection type.
 110    /// This corresponds to the endpoint type, i.e., "tcp", "udp", etc.
 111    /// </summary>
 112    /// <returns>The type of the connection.</returns>
 113    string type();
 114
 115    /// <summary>
 116    /// Returns the connection information.
 117    /// </summary>
 118    /// <returns>The connection information.</returns>
 119    ConnectionInfo getInfo();
 120
 121    /// <summary>
 122    /// Set the connection buffer receive/send size.
 123    /// </summary>
 124    /// <param name="rcvSize">The connection receive buffer size.</param>
 125    /// <param name="sndSize">The connection send buffer size.</param>
 126    void setBufferSize(int rcvSize, int sndSize);
 127
 128    /// <summary>
 129    /// Throw an exception indicating the reason for connection closure.
 130    /// For example,
 131    /// CloseConnectionException is raised if the connection was closed gracefully, whereas
 132    /// ConnectionAbortedException/ConnectionClosedException is raised if the connection was manually closed by
 133    /// the application. This operation does nothing if the connection is not yet closed.
 134    /// </summary>
 135    void throwException();
 136}
 137
 138/// <summary>
 139///  Base class providing access to the connection details.
 140/// </summary>
 141public class ConnectionInfo
 142{
 143    /// <summary>
 144    /// The underlying connection information.
 145    /// </summary>
 146    public readonly ConnectionInfo? underlying;
 147
 148    /// <summary>
 149    /// Whether the connection is an incoming connection (<c>true</c>) or an outgoing connection (<c>false</c>).
 150    /// </summary>
 151    public readonly bool incoming;
 152
 153    /// <summary>
 154    /// The name of the adapter associated with the connection.
 155    /// </summary>
 156    public readonly string adapterName;
 157
 158    /// <summary>
 159    /// The connection id.
 160    /// </summary>
 161    public readonly string connectionId;
 162
 163    protected ConnectionInfo(ConnectionInfo underlying)
 164    {
 165        this.underlying = underlying;
 166        incoming = underlying.incoming;
 167        adapterName = underlying.adapterName;
 168        connectionId = underlying.connectionId;
 169    }
 170
 171    protected ConnectionInfo(bool incoming, string adapterName, string connectionId)
 172    {
 173        this.incoming = incoming;
 174        this.adapterName = adapterName;
 175        this.connectionId = connectionId;
 176    }
 177}
 178
 179public class IPConnectionInfo : ConnectionInfo
 180{
 181    public readonly string localAddress;
 182    public readonly int localPort;
 183    public readonly string remoteAddress;
 184    public readonly int remotePort;
 185
 186    protected IPConnectionInfo(
 187        bool incoming,
 188        string adapterName,
 189        string connectionId,
 190        string localAddress,
 191        int localPort,
 192        string remoteAddress,
 193        int remotePort)
 194        : base(incoming, adapterName, connectionId)
 195    {
 196        this.localAddress = localAddress;
 197        this.localPort = localPort;
 198        this.remoteAddress = remoteAddress;
 199        this.remotePort = remotePort;
 200    }
 201}
 202
 203public sealed class TCPConnectionInfo : IPConnectionInfo
 204{
 205    public readonly int rcvSize;
 206    public readonly int sndSize;
 207
 208    internal TCPConnectionInfo(
 209        bool incoming,
 210        string adapterName,
 211        string connectionId,
 212        string localAddress,
 213        int localPort,
 214        string remoteAddress,
 215        int remotePort,
 216        int rcvSize,
 217        int sndSize)
 218        : base(incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort)
 219    {
 220        this.rcvSize = rcvSize;
 221        this.sndSize = sndSize;
 222    }
 223
 224    internal TCPConnectionInfo(bool incoming, string adapterName, string connectionId)
 225        : this(
 226            incoming,
 227            adapterName,
 228            connectionId,
 229            localAddress: "",
 230            localPort: -1,
 231            remoteAddress: "",
 232            remotePort: -1,
 233            rcvSize: 0,
 234            sndSize: 0)
 235    {
 236    }
 237}
 238
 239public sealed class UDPConnectionInfo : IPConnectionInfo
 240{
 241    public readonly string mcastAddress;
 242    public readonly int mcastPort;
 243    public readonly int rcvSize;
 244    public readonly int sndSize;
 245
 246    internal UDPConnectionInfo(
 247        bool incoming,
 248        string adapterName,
 249        string connectionId,
 250        string localAddress,
 251        int localPort,
 252        string remoteAddress,
 253        int remotePort,
 254        string mcastAddress,
 255        int mcastPort,
 256        int rcvSize,
 257        int sndSize)
 258        : base(incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort)
 259    {
 260        this.mcastAddress = mcastAddress;
 261        this.mcastPort = mcastPort;
 262        this.rcvSize = rcvSize;
 263        this.sndSize = sndSize;
 264    }
 265
 266    internal UDPConnectionInfo(bool incoming, string adapterName, string connectionId)
 267        : this(
 268            incoming,
 269            adapterName,
 270            connectionId,
 271            localAddress: "",
 272            localPort: -1,
 273            remoteAddress: "",
 274            remotePort: -1,
 275            mcastAddress: "",
 276            mcastPort: -1,
 277            rcvSize: 0,
 278            sndSize: 0)
 279    {
 280    }
 281}
 282
 283public sealed class WSConnectionInfo : ConnectionInfo
 284{
 285    public readonly Dictionary<string, string> headers;
 286
 287    internal WSConnectionInfo(ConnectionInfo underlying, Dictionary<string, string> headers)
 1288        : base(underlying) => this.headers = headers;
 289}