internal SimpleInMemConnection(
            SimpleInMemListener parentListener, ConnectionType connectionType,
            ServiceHost serviceHost, SimpleInMemTransport transport,
            Logger logger, Metrics metrics)
        {
            if (parentListener == null)
            {
                throw new ArgumentNullException(nameof(parentListener));
            }
            if (serviceHost == null)
            {
                throw new ArgumentNullException(nameof(serviceHost));
            }
            if (transport == null)
            {
                throw new ArgumentNullException(nameof(transport));
            }

            this.parentListener = parentListener;
            this.connectionType = connectionType;
            this.serviceHost    = serviceHost;
            this.transport      = transport;
            writeQueue          = new InMemFrameQueue();

            // start at -1 or 0 so the first conversation ID is 1 or 2.
            prevConversationId = (connectionType == ConnectionType.Client) ? -1 : 0;
            state = CnxState.Created;

            this.logger  = logger;
            this.metrics = metrics;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new listener using parentTransport and address.
        /// </summary>
        /// <exception cref="ArgumentNullException">parentTransport is null</exception>
        /// <exception cref="ArgumentException">address is null or empty</exception>
        public SimpleInMemListener(
            SimpleInMemTransport parentTransport, string address,
            Logger logger, Metrics metrics) : base(logger, metrics)
        {
            if (parentTransport == null)
            {
                throw new ArgumentNullException(nameof(parentTransport));
            }
            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentException(nameof(address));
            }

            this.address    = address;
            serviceHost     = new ServiceHost(parentTransport, logger, metrics);
            connectionPairs = new Dictionary <Guid, ConnectionPair>();
            logname         = $"{nameof(SimpleInMemListener)}({this.address})";
        }