< Summary

Information
Class: Ice.IPEndpointInfo
Assembly: Ice
File(s): /_/csharp/src/Ice/Endpoint.cs
Tag: 91_21789722663
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 192
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)

/_/csharp/src/Ice/Endpoint.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3#nullable enable
 4
 5namespace Ice;
 6
 7/// <summary>
 8/// An endpoint specifies the address of the server-end of an Ice connection.
 9/// An object adapter listens on one or more endpoints and a client establishes a connection to an endpoint.
 10/// </summary>
 11public interface Endpoint
 12{
 13    /// <summary>
 14    /// Returns this endpoint's information.
 15    /// </summary>
 16    /// <returns>This endpoint's information class.</returns>
 17    EndpointInfo getInfo();
 18}
 19
 20/// <summary>
 21/// Base class for the endpoint info classes.
 22/// </summary>
 23public class EndpointInfo
 24{
 25    /// <summary>
 26    /// The information of the underlying endpoint or null if there's no underlying endpoint.
 27    /// </summary>
 28    public readonly EndpointInfo? underlying;
 29
 30    /// <summary>
 31    /// Specifies whether or not compression should be used if available when using this endpoint.
 32    /// </summary>
 33    public readonly bool compress;
 34
 35    /// <summary>
 36    /// Returns the type of the endpoint.
 37    /// </summary>
 38    /// <returns>The endpoint type.</returns>
 39    public virtual short type() => underlying?.type() ?? -1;
 40
 41    /// <summary>
 42    /// Returns <see langword="true"/> if this endpoint's transport is a datagram transport (namely, UDP),
 43    /// <see langword="false"/> otherwise.
 44    /// </summary>
 45    /// <returns><see langword="true"/> for a UDP endpoint, <see langword="false"/> otherwise.</returns>
 46    public virtual bool datagram() => underlying?.datagram() ?? false;
 47
 48    /// <summary>
 49    /// Returns <see langword="true"/> if this endpoint's transport uses SSL, <see langword="false"/> otherwise.
 50    /// </summary>
 51    /// <returns><see langword="true"/> for SSL and SSL-based transports, <see langword="false"/> otherwise.</returns>
 52    public virtual bool secure() => underlying?.secure() ?? false;
 53
 54    protected EndpointInfo(EndpointInfo underlying)
 55    {
 56        this.underlying = underlying;
 57        compress = underlying.compress;
 58    }
 59
 60    protected EndpointInfo(bool compress) => this.compress = compress;
 61}
 62
 63/// <summary>
 64/// Provides access to the address details of an IP endpoint.
 65/// </summary>
 66/// <seealso cref="Endpoint"/>
 67public class IPEndpointInfo : EndpointInfo
 68{
 69    /// <summary>
 70    /// The host or address configured with the endpoint.
 71    /// </summary>
 72    public readonly string host;
 73
 74    /// <summary>
 75    /// The port number.
 76    /// </summary>
 77    public readonly int port;
 78
 79    /// <summary>
 80    /// The source IP address.
 81    /// </summary>
 82    public readonly string sourceAddress;
 83
 84    protected IPEndpointInfo(bool compress, string host, int port, string sourceAddress)
 185        : base(compress)
 86    {
 187        this.host = host;
 188        this.port = port;
 189        this.sourceAddress = sourceAddress;
 190    }
 91}
 92
 93/// <summary>
 94/// Provides access to a TCP endpoint information.
 95/// </summary>
 96public sealed class TCPEndpointInfo : IPEndpointInfo
 97{
 98    private readonly bool _secure;
 99    private readonly short _type;
 100
 101    public override short type() => _type;
 102
 103    public override bool secure() => _secure;
 104
 105    internal TCPEndpointInfo(
 106        bool compress,
 107        string host,
 108        int port,
 109        string sourceAddress,
 110        short type,
 111        bool secure)
 112        : base(compress, host, port, sourceAddress)
 113    {
 114        _type = type;
 115        _secure = secure;
 116    }
 117}
 118
 119/// <summary>
 120/// Provides access to a UDP endpoint information.
 121/// </summary>
 122public sealed class UDPEndpointInfo : IPEndpointInfo
 123{
 124    /// <summary>
 125    /// The multicast interface.
 126    /// </summary>
 127    public readonly string mcastInterface;
 128
 129    /// <summary>
 130    /// The multicast time-to-live (or hops).
 131    /// </summary>
 132    public readonly int mcastTtl;
 133
 134    public override short type() => UDPEndpointType.value;
 135
 136    public override bool datagram() => true;
 137
 138    internal UDPEndpointInfo(
 139        bool compress,
 140        string host,
 141        int port,
 142        string sourceAddress,
 143        string mcastInterface,
 144        int mcastTtl)
 145        : base(compress, host, port, sourceAddress)
 146    {
 147        this.mcastInterface = mcastInterface;
 148        this.mcastTtl = mcastTtl;
 149    }
 150}
 151
 152/// <summary>
 153/// Provides access to a WebSocket endpoint information.
 154/// </summary>
 155public sealed class WSEndpointInfo : EndpointInfo
 156{
 157    /// <summary>
 158    /// The URI configured with the endpoint.
 159    /// </summary>
 160    public readonly string resource;
 161
 162    internal WSEndpointInfo(EndpointInfo underlying, string resource)
 163        : base(underlying) => this.resource = resource;
 164}
 165
 166/// <summary>
 167/// Provides access to the details of an opaque endpoint.
 168/// </summary>
 169public sealed class OpaqueEndpointInfo : EndpointInfo
 170{
 171    /// <summary>
 172    /// The encoding version of the opaque endpoint (to decode or encode the rawBytes).
 173    /// </summary>
 174    public readonly EncodingVersion rawEncoding;
 175
 176    /// <summary>
 177    /// The raw encoding of the opaque endpoint.
 178    /// </summary>
 179    public readonly byte[] rawBytes;
 180
 181    private readonly short _type;
 182
 183    public override short type() => _type;
 184
 185    internal OpaqueEndpointInfo(short type, EncodingVersion rawEncoding, byte[] rawBytes)
 186        : base(compress: false)
 187    {
 188        _type = type;
 189        this.rawEncoding = rawEncoding;
 190        this.rawBytes = rawBytes;
 191    }
 192}