예제 #1
0
        protected AWorker(WorkerManager manager, GroupTopic groupTopic, string workerId)
        {
            Manager  = manager;
            Group    = groupTopic.Group;
            Topic    = groupTopic.Topic;
            WorkerId = workerId;

            if (groupTopic.Dynamic)
            {
                //todo: deal with dynamic groups/topics
                DynamicSubLoop();
            }
        }
        public AgentAdaptiveWorker(WorkerManager manager, GroupTopic groupTopic, string workerId)
            : base(manager, groupTopic, workerId)
        {
            reqTopic = new TopicListener(Manager.Paths.GetAvailableReq(Topic), Manager.Client);
            reqTopic.MqttMessageReceived += ReqTopic_MqttMessageReceived;

            workTopic = new TopicListener(Manager.Paths.GetDoWork(Group, WorkerId, Topic), Manager.Client);
            workTopic.MqttMessageReceived += WorkTopic_MqttMessageReceived;

            dontWorkTopic = new TopicListener(Manager.Paths.GetDontWork(Group), Manager.Client);
            dontWorkTopic.MqttMessageReceived += DontWorkTopic_MqttMessageReceived;

            manager.Workers.Add(this);
        }