示例#1
0
        public override Task OnActivateAsync()
        {
            this.userStocks = new Dictionary<Guid, HashSet<Stock>>();
            this.subscribers = new ObserverSubscriptionManager<IStockObserver>();

            return TaskDone.Done;
        }
示例#2
0
        //---------------------------------------------------------------------
        public override Task OnActivateAsync()
        {
            DelayDeactivation(TimeSpan.FromMinutes(60));

            Tm4CouchbaseQue = 0f;
            Subscribers     = new ObserverSubscriptionManager <ICellPlayerObserver>();

            if (this.State != null && !string.IsNullOrEmpty(this.State.entity_guid))
            {
                if (AsyncStream == null)
                {
                    IStreamProvider stream_provider = GetStreamProvider(StringDef.SMSProvider);
                    AsyncStream = stream_provider.GetStream <StreamData>(this.GetPrimaryKey(), "Friend");
                }

                if (CouchbaseQue == null)
                {
                    CouchbaseQue = new CouchbaseQue("EtPlayer", this.State.entity_guid);
                }

                EtPlayer = EntityMgr.Instance.genEntity <EtPlayer, GrainCellPlayer>(this.State, this);
            }

            StopwatchUpdate   = new Stopwatch();
            TimerHandleUpdate = RegisterTimer((_) => _update(), null, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(50));
            TimerHandleSave   = RegisterTimer((_) => _save(), null, TimeSpan.FromMilliseconds(10000), TimeSpan.FromMilliseconds(10000));

            return(base.OnActivateAsync());
        }
示例#3
0
 public override Task OnActivateAsync()
 {
     observers = new ObserverSubscriptionManager <IRoomObserver>();
     players   = new List <long>();
     mgr       = GrainFactory.GetGrain <IProcessManager>(0);
     return(TaskDone.Done);
 }
        public override Task OnActivateAsync()
        {
            try
            {
                logger = GetLogger(nameof(ClusterMetricsGrain));

                Configuration = new MetricsConfiguration();

                ClusterSnapshot = new MetricsSnapshot {
                    Source = nameof(ClusterMetricsGrain)
                };
                SiloSnapshots = new Dictionary <string, MetricsSnapshot>();

                Subscribers = new ObserverSubscriptionManager <IClusterMetricsGrainObserver>();

                return(base.OnActivateAsync());
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.TrackException(ex);
                }

                throw;
            }
        }
示例#5
0
 public override Task OnActivateAsync()
 {
     players       = new HashSet <long>();
     subscribers   = new ObserverSubscriptionManager <IGameObserver>();
     playersEvents = new Dictionary <long, IAsyncStream <Progression> >();
     return(base.OnActivateAsync());
 }
示例#6
0
        public override Task OnActivateAsync()
        {
            ReceivedMessagesCacheSize  = 100;
            PublishedMessagesCacheSize = 100;
            if (State.RecentReceivedMessages == null)
            {
                State.RecentReceivedMessages = new Queue <ChirperMessage>(ReceivedMessagesCacheSize);
            }
            if (State.MyPublishedMessages == null)
            {
                State.MyPublishedMessages = new Queue <ChirperMessage>(PublishedMessagesCacheSize);
            }
            if (State.Followers == null)
            {
                State.Followers = new Dictionary <ChirperUserInfo, IChirperSubscriber>();
            }
            if (State.Subscriptions == null)
            {
                State.Subscriptions = new Dictionary <ChirperUserInfo, IChirperPublisher>();
            }

            State.UserId = this.GetPrimaryKeyLong();

            logger = GetLogger("ChirperAccountGrain");

            if (logger.IsVerbose)
            {
                logger.Verbose("{0}: Created activation of ChirperAccount grain.", Me);
            }

            viewers = new ObserverSubscriptionManager <IChirperViewer>();
            // Viewers are transient connections -- they will need to reconnect themselves
            return(TaskDone.Done);
        }
示例#7
0
        public override Task OnActivateAsync()
        {
            _observers = new ObserverSubscriptionManager <IVehicleTrackingObserver>();

            RegisterTimer(Callback, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return(base.OnActivateAsync());
        }
 public override Task OnActivateAsync()
 {
     EventDelay = 1000;
     Observers = new ObserverSubscriptionManager<ISimpleGrainObserver>();
     logger = GetLogger(String.Format("{0}-{1}-{2}", typeof(SimpleObserverableGrain).Name, base.IdentityString, base.RuntimeIdentity));
     logger.Info("Activate.");
     return TaskDone.Done;
 }
示例#9
0
 public override Task OnActivateAsync()
 {
     EventDelay = 1000;
     Observers  = new ObserverSubscriptionManager <ISimpleGrainObserver>();
     logger     = GetLogger(String.Format("{0}-{1}-{2}", typeof(SimpleObserverableGrain).Name, base.IdentityString, base.RuntimeIdentity));
     logger.Info("Activate.");
     return(TaskDone.Done);
 }
示例#10
0
        public override Task OnActivateAsync()
        {
            subscribers   = new ObserverSubscriptionManager <IProcessMgrObserver>();
            sessionStatus = new Dictionary <Guid, bool>();
            source        = new Queue <TaskCompletionSource <Guid> >();

            return(base.OnActivateAsync());
        }
示例#11
0
        public override Task OnActivateAsync()
        {
            temperatures = new Dictionary <long, double>();
            observers    = new ObserverSubscriptionManager <ISystemObserver>();
            var timer = RegisterTimer(Callback, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return(base.OnActivateAsync());
        }
示例#12
0
        public override Task OnActivateAsync()
        {
            _lobby          = new Lobby();
            _lobby.OnReady += Lobby_OnReady;

            this._observers = new ObserverSubscriptionManager <ILobbyObserver>();
            return(base.OnActivateAsync());
        }
示例#13
0
        //---------------------------------------------------------------------
        public override Task OnActivateAsync()
        {
            Subscribers = new ObserverSubscriptionManager<IGFClientObserver>();

            Logger.Info("OnActivateAsync() GrainId={0}", this.GetPrimaryKey().ToString());

            return base.OnActivateAsync();
        }
示例#14
0
        public override Task OnActivateAsync()
        {
            this._guideObservers     = new ObserverSubscriptionManager <IGuideObserver>();
            this._scavengerObservers = new ObserverSubscriptionManager <IScavengerObserver>();
            _scavenger = new Domain.Scavenger();

            return(base.OnActivateAsync());
        }
示例#15
0
        public override Task OnActivateAsync()
        {
            _subsManager = new ObserverSubscriptionManager <IAccountReplicated>();
            var replicatedRef = GrainFactory.GetGrain <IAccountReplicated>(this.GrainId);

            _subsManager.Subscribe(replicatedRef);
            return(base.OnActivateAsync());
        }
        //private ProjectState State;

        //private Task WriteStateAsync()
        //{
        //	return TaskDone.Done;
        //}

        //private Task ClearStateAsync()
        //{
        //	return TaskDone.Done;
        //}

        public override async Task OnActivateAsync()
        {
            //this.State = new ProjectState();

            await StatsHelper.RegisterActivation("ProjectCodeProviderGrain", this.GrainFactory);

            Logger.OrleansLogger = this.GetLogger();
            Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Enter");

            // Logger.LogWarning(this.GetLogger(), "ProjectGrain", "OnActivate", "Entering Project: {0}", this.GetPrimaryKeyString());

            this.observers          = new ObserverSubscriptionManager <IEntityGrainObserverNotifications>();
            this.State.AssemblyName = this.GetPrimaryKeyString();

            //Task.Run(async () =>
            //await Task.Factory.StartNew(async () =>
            //{
            try
            {
                this.RaiseStateChangedEvent(EntityGrainStatus.Busy);

                if (!string.IsNullOrEmpty(this.State.ProjectPath))
                {
                    this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromProjectAsync(this.GrainFactory, this.State.ProjectPath);
                }
                else if (!string.IsNullOrEmpty(this.State.Source) && !String.IsNullOrEmpty(this.State.AssemblyName))
                {
                    this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromSourceAsync(this.GrainFactory, this.State.Source, this.State.AssemblyName);
                }
                else if (!string.IsNullOrEmpty(this.State.TestName) && !String.IsNullOrEmpty(this.State.AssemblyName))
                {
                    this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromTestAsync(this.GrainFactory, this.State.TestName, this.State.AssemblyName);
                }
                else if (this.State.AssemblyName.Equals("DUMMY"))
                {
                    this.projectCodeProvider = new OrleansDummyProjectCodeProvider(this.GrainFactory);

                    await this.WriteStateAsync();
                }

                this.RaiseStateChangedEvent(EntityGrainStatus.Ready);
            }
            catch (Exception ex)
            {
                var inner = ex;
                while (inner is AggregateException)
                {
                    inner = inner.InnerException;
                }

                Logger.LogError(this.GetLogger(), "ProjectGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner);
                throw ex;
            }
            //});

            Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Exit");
        }
示例#17
0
        public override Task OnActivateAsync()
        {
            subscribers = new ObserverSubscriptionManager <IObserve>();

            // set up timer to simulate events to subscribe to
            RegisterTimer(SendOutUpdates, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return(TaskDone.Done);
        }
示例#18
0
        public override Task ActivateAsync()
        {
            subscribers = new ObserverSubscriptionManager<IObserve>();

            // set up timer to simulate events to subscribe to
            RegisterTimer(SendOutUpdates, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return TaskDone.Done;
        }
        public override Task OnActivateAsync()
        {
            this.tempratures = new Dictionary<long, double>();
            // we need to see how many obsevers are there. initialize here.
            this.observers = new ObserverSubscriptionManager<ISystemObserver>();
            // this is just an IDisposable type so that you can cancel the timer.
            var timer = this.RegisterTimer(this.Callback, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return base.OnActivateAsync();
        }
示例#20
0
        public override Task OnActivateAsync()
        {
            this.tempratures = new Dictionary <long, double>();
            // we need to see how many obsevers are there. initialize here.
            this.observers = new ObserverSubscriptionManager <ISystemObserver>();
            // this is just an IDisposable type so that you can cancel the timer.
            var timer = this.RegisterTimer(this.Callback, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return(base.OnActivateAsync());
        }
示例#21
0
        public async override Task ActivateAsync()
        {
            this.observers = new ObserverSubscriptionManager<IMessageObserver>();
            this.otherGrains = new IPubSubGrain[] { };

            var manager = PubSubManagerFactory.GetGrain(0);
            this.otherGrains = await manager.Register(this);

            await base.ActivateAsync();
        }
示例#22
0
        public async override Task ActivateAsync()
        {
            this.observers   = new ObserverSubscriptionManager <IMessageObserver>();
            this.otherGrains = new IPubSubGrain[] { };

            var manager = PubSubManagerFactory.GetGrain(0);

            this.otherGrains = await manager.Register(this);

            await base.ActivateAsync();
        }
示例#23
0
        public override Task OnActivateAsync()
        {
            _subsManager = new ObserverSubscriptionManager <IMapObserver>();
            RegisterOrUpdateReminder("reminder_" + this.GetPrimaryKeyString(), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));

            timer = RegisterTimer((a) =>
            {
                Tick(TickCount++);
                return(Task.CompletedTask);
            }, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));

            return(base.OnActivateAsync());
        }
示例#24
0
        public override Task OnActivateAsync()
        {
            this.dealer = this.GrainFactory.GetGrain <IDealer>(NewGuid());

            var registry = this.GrainFactory.GetGrain <IMatchRegistry>("match_registry");

            registry.AddMatch(this);

            this.game       = new Game();
            this.players    = new ObserverSubscriptionManager <IPlayer>();
            this.spectators = new ObserverSubscriptionManager <IPlayer>();

            return(base.OnActivateAsync());
        }
示例#25
0
        public override async Task OnActivateAsync()
        {
            Console.WriteLine($"{typeof(MainEntryGrain)}OnActivateAsync");


            m_Timer       = RegisterTimer(Update_Timer, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
            m_subsManager = new ObserverSubscriptionManager <IMainEntry_Obs>();

            var streamProvider = this.GetStreamProvider(GameConstant.HallStreamProvider);

            m_Stream = streamProvider.GetStream <string>(Guid.NewGuid(), GameConstant.HallStreamInput);

            m_SSHandle = await m_Stream.SubscribeAsync(this);


            await base.OnActivateAsync();
        }
示例#26
0
        public override async Task OnActivateAsync()
        {
            await StatsHelper.RegisterActivation("EffectsDispatcherGrain", this.GrainFactory);

            this.isDispatchingEffects = false;
            this.status             = EffectsDispatcherStatus.Inactive;
            this.lastProcessingTime = DateTime.UtcNow;             // DateTime.MinValue; // DateTime.MaxValue;
            this.solutionGrain      = OrleansSolutionManager.GetSolutionGrain(this.GrainFactory);
            this.effectsDispatcher  = new OrleansEffectsDispatcherManager(this.GrainFactory, this.solutionGrain);

            this.subscriptionManager = new ObserverSubscriptionManager <IAnalysisObserver>();

            var streamProvider = this.GetStreamProvider(AnalysisConstants.StreamProvider);
            var stream         = streamProvider.GetStream <PropagationEffects>(this.GetPrimaryKey(), AnalysisConstants.StreamNamespace);
            //await stream.SubscribeAsync(this);

            // Explicit subscription code
            var subscriptionHandles = await stream.GetAllSubscriptionHandles();

            if (subscriptionHandles != null && subscriptionHandles.Count > 0)
            {
                var tasks = new List <Task>();

                foreach (var subscriptionHandle in subscriptionHandles)
                {
                    var task = subscriptionHandle.ResumeAsync(this);
                    //await task;
                    tasks.Add(task);
                }

                await Task.WhenAll(tasks);
            }
            else
            {
                await stream.SubscribeAsync(this);
            }

            var period = TimeSpan.FromMilliseconds(AnalysisConstants.DispatcherTimerPeriod);

            this.timer = this.RegisterTimer(this.OnTimerTick, null, period, period);

            await base.OnActivateAsync();
        }
示例#27
0
 public ShardSession()
 {
     sessionObservers = new ObserverSubscriptionManager <IShardSessionObserver>();
 }
示例#28
0
文件: Object.cs 项目: soulson/Drama
 public AbstractObject()
 {
     observerManager = new ObserverSubscriptionManager <IObjectObserver>();
 }
示例#29
0
 public override Task ActivateAsync()
 {
     listeners = new ObserverSubscriptionManager <IHubObserver>();
     return(TaskDone.Done);
 }
示例#30
0
 public override Task OnActivateAsync()
 {
     subscribers = new ObserverSubscriptionManager<IGameObserver>();
     players = new HashSet<Guid>();
     return TaskDone.Done;
 }
 public override Task OnActivateAsync()
 {
     _subsManager = new ObserverSubscriptionManager <IClientboundPacketObserver>();
     return(base.OnActivateAsync());
 }
示例#32
0
 public ZoneGrain()
 {
     _subsManager = new ObserverSubscriptionManager <IZoneOb>();
 }
示例#33
0
 public override Task OnActivateAsync()
 {
     _subManager=new ObserverSubscriptionManager<IChat>();
     return base.OnActivateAsync();
 }
示例#34
0
 public override Task ActivateAsync()
 {
     listeners = new ObserverSubscriptionManager<IHubObserver>();
     return TaskDone.Done;
 }
示例#35
0
 public override Task OnActivateAsync()
 {
     subscribers = new ObserverSubscriptionManager <IClientObserver>();
     return(TaskDone.Done);
 }
 public override Task OnActivateAsync()
 {
     subscribers = new ObserverSubscriptionManager<IClientObserver>();
     return TaskDone.Done;
 }
示例#37
0
 public override async Task OnActivateAsync()
 {
     // We created the utility at activation time.
     _subsManager = new ObserverSubscriptionManager <IEventHandler>();
     await base.OnActivateAsync();
 }
示例#38
0
 public override Task OnActivateAsync()
 {
     subscribers = new ObserverSubscriptionManager <IGameObserver>();
     players     = new HashSet <Guid>();
     return(TaskDone.Done);
 }
示例#39
0
 public override Task OnActivateAsync()
 {
     _subscriptionManager = new ObserverSubscriptionManager <IMessageHub>();
     return(base.OnActivateAsync());
 }