Ejemplo n.º 1
0
 internal static EpoxyConnection MakeServerConnection(
     EpoxyTransport parentTransport,
     EpoxyListener parentListener,
     ServiceHost serviceHost,
     Socket socket)
 {
     return(new EpoxyConnection(
                ConnectionType.Server,
                parentTransport,
                parentListener,
                serviceHost,
                socket));
 }
Ejemplo n.º 2
0
        internal static EpoxyConnection MakeClientConnection(
            EpoxyTransport parentTransport,
            Socket clientSocket)
        {
            const EpoxyListener parentListener = null;

            return(new EpoxyConnection(
                       ConnectionType.Client,
                       parentTransport,
                       parentListener,
                       new ServiceHost(parentTransport),
                       clientSocket));
        }
Ejemplo n.º 3
0
 internal static EpoxyConnection MakeServerConnection(
     EpoxyTransport parentTransport,
     EpoxyListener parentListener,
     ServiceHost serviceHost,
     EpoxyNetworkStream networkStream,
     Logger logger,
     Metrics metrics)
 {
     return(new EpoxyConnection(
                ConnectionType.Server,
                parentTransport,
                parentListener,
                serviceHost,
                networkStream,
                logger,
                metrics));
 }
Ejemplo n.º 4
0
        internal static EpoxyConnection MakeClientConnection(
            EpoxyTransport parentTransport,
            EpoxyNetworkStream networkStream,
            Logger logger,
            Metrics metrics)
        {
            const EpoxyListener parentListener = null;

            return(new EpoxyConnection(
                       ConnectionType.Client,
                       parentTransport,
                       parentListener,
                       new ServiceHost(logger),
                       networkStream,
                       logger,
                       metrics));
        }
Ejemplo n.º 5
0
        private EpoxyConnection(
            ConnectionType connectionType,
            EpoxyTransport parentTransport,
            EpoxyListener parentListener,
            ServiceHost serviceHost,
            Socket socket,
            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(socket != null);

            this.connectionType = connectionType;

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

            netSocket = new EpoxySocket(socket, logger);

            // cache these so we can use them after the socket has been shutdown
            LocalEndPoint  = (IPEndPoint)socket.LocalEndPoint;
            RemoteEndPoint = (IPEndPoint)socket.RemoteEndPoint;

            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.connection_id   = Guid.NewGuid().ToString();
            connectionMetrics.local_endpoint  = LocalEndPoint.ToString();
            connectionMetrics.remote_endpoint = RemoteEndPoint.ToString();

            this.logger  = logger;
            this.metrics = metrics;
        }
Ejemplo n.º 6
0
        private EpoxyConnection(
            ConnectionType connectionType,
            EpoxyTransport parentTransport,
            EpoxyListener parentListener,
            ServiceHost serviceHost,
            EpoxyNetworkStream 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;
        }