示例#1
0
        public void Dispose()
        {
            foreach (var item in ActorCollect)
            {
                item.Value.Dispose();
            }

            ActorCollect.Clear();
        }
示例#2
0
 public ValueTask AsyncAction(long id, int cmd, OpenAccess access, params object[] args)
 {
     if (ActorCollect.TryGetValue(cmd, out Actor m))
     {
         return(m.AsyncAction(id, cmd, access, args));
     }
     else
     {
         throw new NetxException($"not found actor service cmd:{cmd}", ErrorType.ActorErr);
     }
 }
示例#3
0
 public void SyncAction(long id, int cmd, OpenAccess access, params object[] args)
 {
     if (ActorCollect.ContainsKey(cmd))
     {
         ActorCollect[cmd].Action(id, cmd, access, args);
     }
     else
     {
         Log.ErrorFormat("not found actor service cmd:{cmd}", cmd);
     }
 }
示例#4
0
 public MethodRegister?GetCmdService(int cmd)
 {
     if (ActorCollect.ContainsKey(cmd))
     {
         return(ActorCollect[cmd].CmdDict[cmd]);
     }
     else
     {
         return(null);
     }
 }
示例#5
0
        public LambdaActorRun(string key, IServiceProvider container, LambdaController lambdaController)
            : base(container, container.GetRequiredService <ILoggerFactory>().CreateLogger("LambdaActorRun->"))
        {
            Key          = key;
            actorCollect = new Lazy <ConcurrentDictionary <int, Actor> >();
            var actor = new Actor(Container, this, ActorScheduler, lambdaController);

            actor.CompletedEvent += Actor_CompletedEvent;
            foreach (int cmd in actor.CmdDict.Keys)
            {
                ActorCollect.AddOrUpdate(cmd, actor, (a, b) => actor);
            }

            if (ActorCollect.Count > 0)
            {
                Task.Factory.StartNew(SleepingHandler);
            }

            foreach (var @event in container.GetServices <ActorEventBase>())
            {
                this.CompletedEvent += @event.ActorEventCompleted;
            }
        }