Exemplo n.º 1
0
        protected override ActorChannelConfiguration BuildChannelConfiguration()
        {
            var configuration = new ActorChannelConfiguration();

            if (_appConfig.ContainsItem(AppConfigActorSettingItems.KeepAliveIntervalKey))
            {
                var keepAliveInterval = _appConfig.GetItem <int>(AppConfigActorSettingItems.KeepAliveIntervalKey);
                if (keepAliveInterval < 1)
                {
                    throw new InvalidProgramException(
                              string.Format("Item [{0}] setting is invalid.", AppConfigActorSettingItems.KeepAliveIntervalKey));
                }
                configuration.KeepAliveInterval = TimeSpan.FromMilliseconds(keepAliveInterval);
            }

            if (_appConfig.ContainsItem(AppConfigActorSettingItems.KeepAliveTimeoutKey))
            {
                var keepAliveTimeout = _appConfig.GetItem <int>(AppConfigActorSettingItems.KeepAliveTimeoutKey);
                if (keepAliveTimeout < 1)
                {
                    throw new InvalidProgramException(
                              string.Format("Item [{0}] setting is invalid.", AppConfigActorSettingItems.KeepAliveTimeoutKey));
                }
                configuration.KeepAliveTimeout = TimeSpan.FromMilliseconds(keepAliveTimeout);
            }

            if (_appConfig.ContainsItem(AppConfigActorSettingItems.KeepAliveEnabledKey))
            {
                var keepAliveEnabled = _appConfig.GetItem <bool>(AppConfigActorSettingItems.KeepAliveEnabledKey);
                configuration.KeepAliveEnabled = keepAliveEnabled;
            }

            return(configuration);
        }
Exemplo n.º 2
0
        public ActorConnectorChannel(
            ActorIdentity localActor,
            ActorTransportConnector remoteConnector,
            ActorChannelConfiguration channelConfiguration)
        {
            if (localActor == null)
            {
                throw new ArgumentNullException("localActor");
            }
            if (remoteConnector == null)
            {
                throw new ArgumentNullException("remoteConnector");
            }
            if (channelConfiguration == null)
            {
                throw new ArgumentNullException("channelConfiguration");
            }

            _localActor           = localActor;
            _connector            = remoteConnector;
            _channelConfiguration = channelConfiguration;

            _keepAliveTracker      = KeepAliveTracker.Create(KeepAliveInterval, new TimerCallback((s) => OnKeepAlive()));
            _keepAliveTimeoutTimer = new Timer(new TimerCallback((s) => OnKeepAliveTimeout()), null, Timeout.Infinite, Timeout.Infinite);
        }
Exemplo n.º 3
0
 public ActorConnectorReconnectableChannel(
     ActorIdentity localActor,
     ActorTransportConnector remoteConnector,
     ActorChannelConfiguration channelConfiguration)
     : base(localActor, remoteConnector, channelConfiguration)
 {
     this.RetryPeriod = TimeSpan.FromSeconds(15);
 }
Exemplo n.º 4
0
        public ActorChannelSession(
            ActorIdentity localActor,
            ActorChannelConfiguration channelConfiguration,
            ActorTransportSession session)
        {
            _localActor           = localActor;
            _channelConfiguration = channelConfiguration;
            _innerSession         = session;

            _keepAliveTracker      = KeepAliveTracker.Create(KeepAliveInterval, new TimerCallback((s) => OnKeepAlive()));
            _keepAliveTimeoutTimer = new Timer(new TimerCallback((s) => OnKeepAliveTimeout()), null, Timeout.Infinite, Timeout.Infinite);
        }
Exemplo n.º 5
0
        public ActorChannelFactory(
            IActorDirectory directory,
            ActorChannelConfiguration channelConfiguration)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (channelConfiguration == null)
            {
                throw new ArgumentNullException("channelConfiguration");
            }

            _directory            = directory;
            _channelConfiguration = channelConfiguration;
        }
Exemplo n.º 6
0
        public CenterActorDirectory(
            ActorIdentity centerActor,
            ActorChannelConfiguration channelConfiguration)
        {
            if (centerActor == null)
            {
                throw new ArgumentNullException("centerActor");
            }
            if (channelConfiguration == null)
            {
                throw new ArgumentNullException("channelConfiguration");
            }

            _centerActor          = centerActor;
            _channelConfiguration = channelConfiguration;
        }
Exemplo n.º 7
0
        private ConcurrentDictionary <string, string> _actorKeys             = new ConcurrentDictionary <string, string>();              // ActorKey -> SessionKey

        public ActorListenerChannel(
            ActorIdentity localActor,
            ActorTransportListener localListener,
            ActorChannelConfiguration channelConfiguration)
        {
            if (localActor == null)
            {
                throw new ArgumentNullException("localActor");
            }
            if (localListener == null)
            {
                throw new ArgumentNullException("localListener");
            }
            if (channelConfiguration == null)
            {
                throw new ArgumentNullException("channelConfiguration");
            }

            _localActor           = localActor;
            _listener             = localListener;
            _channelConfiguration = channelConfiguration;
        }