Beispiel #1
0
 internal static RelayEpoxyConnection MakeServerConnection(
     RelayEpoxyTransport parentTransport,
     RelayEpoxyListener parentListener,
     ServiceHost serviceHost,
     HybridConnectionStream networkStream,
     Logger logger,
     Metrics metrics)
 {
     return(new RelayEpoxyConnection(
                ConnectionType.Server,
                parentTransport,
                parentListener,
                serviceHost,
                networkStream,
                logger,
                metrics));
 }
Beispiel #2
0
        internal static RelayEpoxyConnection MakeClientConnection(
            RelayEpoxyTransport parentTransport,
            HybridConnectionStream networkStream,
            Logger logger,
            Metrics metrics)
        {
            const RelayEpoxyListener parentListener = null;

            return(new RelayEpoxyConnection(
                       ConnectionType.Client,
                       parentTransport,
                       parentListener,
                       new ServiceHost(logger),
                       networkStream,
                       logger,
                       metrics));
        }
Beispiel #3
0
        RelayEpoxyConnection(
            ConnectionType connectionType,
            RelayEpoxyTransport parentTransport,
            RelayEpoxyListener parentListener,
            ServiceHost serviceHost,
            HybridConnectionStream networkStream,
            Logger logger,
            Metrics metrics)
        {
            Debug.Assert(parentTransport != null);
            Debug.Assert(connectionType != ConnectionType.Server || parentListener != null, "Server connections must have a listener");
            Debug.Assert(serviceHost != null);
            Debug.Assert(networkStream != null);

            this.connectionType = connectionType;

            this.parentTransport = parentTransport;
            this.parentListener  = parentListener;
            this.serviceHost     = serviceHost;

            this.networkStream = networkStream;

            responseMap = new ResponseMap();

            state               = State.Created;
            startTask           = new TaskCompletionSource <bool>();
            stopTask            = new TaskCompletionSource <bool>();
            shutdownTokenSource = new CancellationTokenSource();

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

            //ConnectionMetrics.local_endpoint = LocalEndPoint.ToString();
            //ConnectionMetrics.remote_endpoint = RemoteEndPoint.ToString();

            this.logger  = logger;
            this.metrics = metrics;
        }
Beispiel #4
0
        public RelayEpoxyListener(
            RelayEpoxyTransport parentTransport,
            string listenEndpoint,
            TokenProvider tokenProvider,
            Logger logger,
            Metrics metrics) : base(logger, metrics)
        {
            Debug.Assert(parentTransport != null);
            Debug.Assert(listenEndpoint != null);

            this.parentTransport = parentTransport;

            // will be null if not using TLS
            this.tokenProvider = tokenProvider;

            var endpoint = new Uri(listenEndpoint);

            listener            = new HybridConnectionListener(endpoint, tokenProvider);
            serviceHost         = new ServiceHost(logger);
            connections         = new HashSet <RelayEpoxyConnection>();
            shutdownTokenSource = new CancellationTokenSource();
            ListenEndpoint      = endpoint;
        }