Ejemplo n.º 1
0
        private void OnConnectionAccepted(IPEndPoint endPoint, Socket socket)
        {
            var conn = _securityType == TcpSecurityType.Secure
                                ? TcpConnectionSsl.CreateServerFromSocket(Guid.NewGuid(), endPoint, socket, _certificate, verbose: true)
                                : TcpConnection.CreateAcceptedTcpConnection(Guid.NewGuid(), endPoint, socket, verbose: true);

            Log.Information(
                "{serviceType} TCP connection accepted: [{securityType}, {remoteEndPoint}, L{localEndPoint}, {connectionId:B}].",
                _serviceType, _securityType, conn.RemoteEndPoint, conn.LocalEndPoint, conn.ConnectionId);

            var dispatcher = _dispatcherFactory(conn.ConnectionId, _serverEndPoint);
            var manager    = new TcpConnectionManager(
                string.Format("{0}-{1}", _serviceType.ToString().ToLower(), _securityType.ToString().ToLower()),
                _serviceType,
                dispatcher,
                _publisher,
                conn,
                _networkSendQueue,
                _authProvider,
                _heartbeatInterval,
                _heartbeatTimeout,
                (m, e) => _publisher.Publish(new TcpMessage.ConnectionClosed(m, e)),
                _connectionPendingSendBytesThreshold,
                _connectionQueueSizeThreshold);                 // TODO AN: race condition

            _publisher.Publish(new TcpMessage.ConnectionEstablished(manager));
            manager.StartReceiving();
        }
Ejemplo n.º 2
0
        private void OnConnectionAccepted(TcpConnection connection)
        {
            Log.Info("Client TCP connection accepted: [{0}]", connection.EffectiveEndPoint);
            var manager = new TcpConnectionManager("REPLICA", _tcpDispatcher, _publisher, connection);

            manager.ConnectionClosed += OnConnectionClosed;

            _publisher.Publish(new TcpMessage.ConnectionEstablished(manager));
            manager.StartReceiving();
        }