Exemple #1
0
        private AeronClient(ClientServerConfig config)
        {
            _config = config;
            AeronDriver.DriverContext    driverContext = config.ToDriverContext();
            Adaptive.Aeron.Aeron.Context clientContext = config.ToClientContext();

            driverContext
            .LoggerInfo(_driverLog.Info)
            .LoggerWarning(_driverLog.Warn)
            .LoggerWarning(_driverLog.Error);

            _driver = AeronDriver.Start(driverContext);

            clientContext
            .ErrorHandler(OnError)
            .AvailableImageHandler(ConnectionOnImageAvailable)
            .UnavailableImageHandler(ConnectionOnImageUnavailable);

            _client = Adaptive.Aeron.Aeron.Connect(clientContext);

            const int sessionsLen =
#if DEBUG
                1;
#else
                64;
#endif

            _clientSessions = new AeronClientSession[sessionsLen];
        }
        public AeronServer(int serverPort, ClientServerConfig config)
        {
            _config        = config;
            _driverContext = config.ToDriverContext();
            _clientContext = config.ToClientContext();

            _driverContext
            .LoggerInfo(_driverLog.Info)
            .LoggerWarning(_driverLog.Warn)
            .LoggerWarning(_driverLog.Error);

            _driver = AeronDriver.Start(_driverContext);

            _clientContext
            .ErrorHandler(OnError)
            .AvailableImageHandler(ConnectionOnImageAvailable)
            .UnavailableImageHandler(ConnectionOnImageUnavailable);

            _client = Adaptive.Aeron.Aeron.Connect(_clientContext);

            _publicationIdleStrategy = _config.ClientIdleStrategy.GetClientIdleStrategy();

            _subscription = _client.AddSubscription($"aeron:udp?endpoint=0.0.0.0:{serverPort}", ServerStreamId);
        }