public TcpConnectionManager(string connectionName, Guid connectionId, ITcpDispatcher dispatcher, IPublisher publisher, string targetHost, EndPoint remoteEndPoint, TcpClientConnector connector, bool useSsl, Func <X509Certificate, X509Chain, SslPolicyErrors, ValueTuple <bool, string> > sslServerCertValidator, Func <X509CertificateCollection> sslClientCertificatesSelector, IPublisher networkSendQueue, IAuthenticationProvider authProvider, AuthorizationGateway authorization, TimeSpan heartbeatInterval, TimeSpan heartbeatTimeout, Action <TcpConnectionManager> onConnectionEstablished, Action <TcpConnectionManager, SocketError> onConnectionClosed) { Ensure.NotEmptyGuid(connectionId, "connectionId"); Ensure.NotNull(dispatcher, "dispatcher"); Ensure.NotNull(publisher, "publisher"); Ensure.NotNull(authProvider, "authProvider"); Ensure.NotNull(authorization, "authorization"); Ensure.NotNull(remoteEndPoint, "remoteEndPoint"); Ensure.NotNull(connector, "connector"); ConnectionId = connectionId; ConnectionName = connectionName; _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 = ESConsts.UnrestrictedPendingSendBytes; _connectionQueueSizeThreshold = ESConsts.MaxConnectionQueueSize; _connectionEstablished = onConnectionEstablished; _connectionClosed = onConnectionClosed; RemoteEndPoint = remoteEndPoint; _connection = useSsl ? connector.ConnectSslTo(ConnectionId, targetHost, remoteEndPoint.ResolveDnsToIPAddress(), ConnectionTimeout, sslServerCertValidator, sslClientCertificatesSelector, OnConnectionEstablished, OnConnectionFailed) : connector.ConnectTo(ConnectionId, remoteEndPoint.ResolveDnsToIPAddress(), ConnectionTimeout, OnConnectionEstablished, OnConnectionFailed); _connection.ConnectionClosed += OnConnectionClosed; if (_connection.IsClosed) { OnConnectionClosed(_connection, SocketError.Success); } }
public TcpConnectionManager(string connectionName, Guid connectionId, ITcpDispatcher dispatcher, IPublisher publisher, IPEndPoint remoteEndPoint, TcpClientConnector connector, bool useSsl, string sslTargetHost, bool sslValidateServer, IPublisher networkSendQueue, IAuthenticationProvider authProvider, TimeSpan heartbeatInterval, TimeSpan heartbeatTimeout, Action <TcpConnectionManager> onConnectionEstablished, Action <TcpConnectionManager, SocketError> onConnectionClosed) { Ensure.NotEmptyGuid(connectionId, "connectionId"); Ensure.NotNull(dispatcher, "dispatcher"); Ensure.NotNull(publisher, "publisher"); Ensure.NotNull(authProvider, "authProvider"); Ensure.NotNull(remoteEndPoint, "remoteEndPoint"); Ensure.NotNull(connector, "connector"); if (useSsl) { Ensure.NotNull(sslTargetHost, "sslTargetHost"); } ConnectionId = connectionId; ConnectionName = connectionName; _tcpEnvelope = new SendOverTcpEnvelope(this, networkSendQueue); _publisher = publisher; _dispatcher = dispatcher; _authProvider = authProvider; _framer = new LengthPrefixMessageFramer(); _framer.RegisterMessageArrivedCallback(OnMessageArrived); _weakThisEnvelope = new SendToWeakThisEnvelope(this); _heartbeatInterval = heartbeatInterval; _heartbeatTimeout = heartbeatTimeout; _connectionPendingSendBytesThreshold = ESConsts.UnrestrictedPendingSendBytes; _connectionQueueSizeThreshold = ESConsts.MaxConnectionQueueSize; _connectionEstablished = onConnectionEstablished; _connectionClosed = onConnectionClosed; RemoteEndPoint = remoteEndPoint; _connection = useSsl ? connector.ConnectSslTo(ConnectionId, remoteEndPoint, ConnectionTimeout, sslTargetHost, sslValidateServer, OnConnectionEstablished, OnConnectionFailed) : connector.ConnectTo(ConnectionId, remoteEndPoint, ConnectionTimeout, OnConnectionEstablished, OnConnectionFailed); _connection.ConnectionClosed += OnConnectionClosed; if (_connection.IsClosed) { OnConnectionClosed(_connection, SocketError.Success); } }
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); }