Beispiel #1
0
        public TcpService(IPublisher publisher,
                          IPEndPoint serverEndPoint,
                          IPublisher networkSendQueue,
                          TcpServiceType serviceType,
                          TcpSecurityType securityType,
                          Func <Guid, IPEndPoint, ITcpDispatcher> dispatcherFactory,
                          TimeSpan heartbeatInterval,
                          TimeSpan heartbeatTimeout,
                          IAuthenticationProvider authProvider,
                          X509Certificate certificate,
                          int connectionPendingSendBytesThreshold)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(serverEndPoint, "serverEndPoint");
            Ensure.NotNull(networkSendQueue, "networkSendQueue");
            Ensure.NotNull(dispatcherFactory, "dispatcherFactory");
            Ensure.NotNull(authProvider, "authProvider");
            if (securityType == TcpSecurityType.Secure)
            {
                Ensure.NotNull(certificate, "certificate");
            }

            _publisher         = publisher;
            _serverEndPoint    = serverEndPoint;
            _serverListener    = new TcpServerListener(_serverEndPoint);
            _networkSendQueue  = networkSendQueue;
            _serviceType       = serviceType;
            _securityType      = securityType;
            _dispatcherFactory = dispatcherFactory;
            _heartbeatInterval = heartbeatInterval;
            _heartbeatTimeout  = heartbeatTimeout;
            _connectionPendingSendBytesThreshold = connectionPendingSendBytesThreshold;
            _authProvider = authProvider;
            _certificate  = certificate;
        }
        public TcpConnectionManager(string connectionName,
                                    TcpServiceType serviceType,
                                    ITcpDispatcher dispatcher,
                                    IPublisher publisher,
                                    ITcpConnection openedConnection,
                                    IPublisher networkSendQueue,
                                    IAuthenticationProvider authProvider,
                                    AuthorizationGateway authorization,
                                    TimeSpan heartbeatInterval,
                                    TimeSpan heartbeatTimeout,
                                    Action <TcpConnectionManager, SocketError> onConnectionClosed,
                                    int connectionPendingSendBytesThreshold,
                                    int connectionQueueSizeThreshold)
        {
            Ensure.NotNull(dispatcher, "dispatcher");
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(openedConnection, "openedConnnection");
            Ensure.NotNull(networkSendQueue, "networkSendQueue");
            Ensure.NotNull(authProvider, "authProvider");
            Ensure.NotNull(authorization, "authorization");
            ConnectionId   = openedConnection.ConnectionId;
            ConnectionName = connectionName;

            _serviceType   = serviceType;
            _tcpEnvelope   = new SendOverTcpEnvelope(this, networkSendQueue);
            _publisher     = publisher;
            _dispatcher    = dispatcher;
            _authProvider  = authProvider;
            _authorization = authorization;

            _framer = new LengthPrefixMessageFramer();
            _framer.RegisterMessageArrivedCallback(OnMessageArrived);

            _weakThisEnvelope  = new SendToWeakThisEnvelope(this);
            _heartbeatInterval = heartbeatInterval;
            _heartbeatTimeout  = heartbeatTimeout;
            _connectionPendingSendBytesThreshold = connectionPendingSendBytesThreshold;
            _connectionQueueSizeThreshold        = connectionQueueSizeThreshold;

            _connectionClosed = onConnectionClosed;

            RemoteEndPoint = openedConnection.RemoteEndPoint;
            _connection    = openedConnection;
            _connection.ConnectionClosed += OnConnectionClosed;
            if (_connection.IsClosed)
            {
                OnConnectionClosed(_connection, SocketError.Success);
                return;
            }

            ScheduleHeartbeat(0);
        }
Beispiel #3
0
 public TcpService(IPublisher publisher,
                   IPEndPoint serverEndPoint,
                   IPublisher networkSendQueue,
                   TcpServiceType serviceType,
                   TcpSecurityType securityType,
                   ITcpDispatcher dispatcher,
                   TimeSpan heartbeatInterval,
                   TimeSpan heartbeatTimeout,
                   IAuthenticationProvider authProvider,
                   X509Certificate certificate)
     : this(publisher, serverEndPoint, networkSendQueue, serviceType, securityType, (_, __) => dispatcher,
            heartbeatInterval, heartbeatTimeout, authProvider, certificate)
 {
 }
Beispiel #4
0
 public TcpService(IPublisher publisher,
                   IPEndPoint serverEndPoint,
                   IPublisher networkSendQueue,
                   TcpServiceType serviceType,
                   TcpSecurityType securityType,
                   ITcpDispatcher dispatcher,
                   TimeSpan heartbeatInterval,
                   TimeSpan heartbeatTimeout,
                   IAuthenticationProvider authProvider,
                   X509Certificate certificate,
                   int connectionPendingSendBytesThreshold,
                   int connectionQueueSizeThreshold)
     : this(publisher, serverEndPoint, networkSendQueue, serviceType, securityType, (_, __) => dispatcher,
            heartbeatInterval, heartbeatTimeout, authProvider, certificate, connectionPendingSendBytesThreshold, connectionQueueSizeThreshold)
 {
 }
Beispiel #5
0
 public TcpService(IPublisher publisher,
                   IPEndPoint serverEndPoint,
                   IPublisher networkSendQueue,
                   TcpServiceType serviceType,
                   TcpSecurityType securityType,
                   ITcpDispatcher dispatcher,
                   TimeSpan heartbeatInterval,
                   TimeSpan heartbeatTimeout,
                   IAuthenticationProvider authProvider,
                   AuthorizationGateway authorizationGateway,
                   X509Certificate certificate,
                   Func <X509Certificate, X509Chain, SslPolicyErrors, ValueTuple <bool, string> > sslClientCertValidator,
                   int connectionPendingSendBytesThreshold,
                   int connectionQueueSizeThreshold)
     : this(publisher, serverEndPoint, networkSendQueue, serviceType, securityType, (_, __) => dispatcher,
            heartbeatInterval, heartbeatTimeout, authProvider, authorizationGateway, certificate, sslClientCertValidator, connectionPendingSendBytesThreshold, connectionQueueSizeThreshold)
 {
 }
Beispiel #6
0
        public TcpService(IPublisher publisher,
                          IPEndPoint serverEndPoint,
                          IPublisher networkSendQueue,
                          TcpServiceType serviceType,
                          TcpSecurityType securityType,
                          Func <Guid, IPEndPoint, ITcpDispatcher> dispatcherFactory,
                          TimeSpan heartbeatInterval,
                          TimeSpan heartbeatTimeout,
                          IAuthenticationProvider authProvider,
                          AuthorizationGateway authorizationGateway,
                          X509Certificate certificate,
                          Func <X509Certificate, X509Chain, SslPolicyErrors, ValueTuple <bool, string> > sslClientCertValidator,
                          int connectionPendingSendBytesThreshold,
                          int connectionQueueSizeThreshold)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(serverEndPoint, "serverEndPoint");
            Ensure.NotNull(networkSendQueue, "networkSendQueue");
            Ensure.NotNull(dispatcherFactory, "dispatcherFactory");
            Ensure.NotNull(authProvider, "authProvider");
            Ensure.NotNull(authorizationGateway, "authorizationGateway");
            if (securityType == TcpSecurityType.Secure)
            {
                Ensure.NotNull(certificate, "certificate");
            }

            _publisher         = publisher;
            _serverEndPoint    = serverEndPoint;
            _serverListener    = new TcpServerListener(_serverEndPoint);
            _networkSendQueue  = networkSendQueue;
            _serviceType       = serviceType;
            _securityType      = securityType;
            _dispatcherFactory = dispatcherFactory;
            _heartbeatInterval = heartbeatInterval;
            _heartbeatTimeout  = heartbeatTimeout;
            _connectionPendingSendBytesThreshold = connectionPendingSendBytesThreshold;
            _connectionQueueSizeThreshold        = connectionQueueSizeThreshold;
            _authProvider           = authProvider;
            _authorizationGateway   = authorizationGateway;
            _certificate            = certificate;
            _sslClientCertValidator = sslClientCertValidator;
        }