Example #1
0
 void Start()
 {
     messenger = new DummyMessenger(this);
     messenger.Connect(OnStateReceived, OnBoardReceived);
     EventManager.StartListening(EventName.Input.BuildHouse(), BuildHouse);
     EventManager.StartListening(EventName.Input.BuildHotel(), BuildHotel);
 }
        public void UpdateFromSettings(AppSettings settings = null)
        {
            if (settings == null)
            {
                settings = Settings;
            }
            else
            {
                Settings = settings;
            }

            HelenApi = Factory.CreateHelenApiInterface(settings.HelenApiUrl);

            settings.ApiId        = HelenApi.GetApiId(settings.Name, settings.ApiId);
            settings.BrokerUrl    = HelenApi.GetBrokerUrl(settings.BrokerUrl);
            capabilities.Settings = settings;

            Messenger = Factory.CreateMessenger(settings);

            Probe.MeasureInterval = settings.MeasureInterval;
            if (Probe is Probes.LinuxTempProbe)
            {
                var lprobe = Probe as Probes.LinuxTempProbe;
                lprobe.OneWireDeviceName = settings.ProbeDeviceName;
            }

            ProbePublisher?.Dispose();
            ProbePublisher = Messenger.GetPublisher(ProbeTopic);

            ConfigPublisher?.Dispose();
            ConfigPublisher                    = Messenger.GetPublisher(ConfigTopic);
            ConfigPublisher.Retain             = true;
            Messenger.ConnectionStatusChanged += (s, e) => ConfigPublisher.Publish(capabilities.Json);

            ConfigListener?.Dispose();
            ConfigListener              = Messenger.GetListener(DeviceConfigTopic);
            ConfigListener.MsgReceived += ConfigListener_MsgReceived;

            HelenApiLocationListener?.Dispose();
            HelenApiLocationListener              = Messenger.GetListener(HelenApi.LocationMessageTopic);
            HelenApiLocationListener.MsgReceived += HelenApiLocationListener_MsgReceived;

            ConsoleExtensions.WriteDebugLocationEnabled = settings.DebugMode;
            Messenger.Connect();
        }
Example #3
0
        public async Task Initialize()
        {
            _log.Info("Initializing bot process.");
            await Task.WhenAll(_modules.Select(async m => await m.Initialize()));

            _log.Debug("Modules initialized.");

            _log.Trace("Connecting to messenger...");
            var connected = await _messenger.Connect();

            if (!connected)
            {
                _log.Warn("Unable to connect to messenger.");
                return;
            }
            _log.Trace("Connected.");

            _messenger.OnMessageReceived += HandleMessage;
        }
Example #4
0
        public static void Connect(IMessenger from, IMessenger to)
        {
            IMessenger KGB = new UncleMajorMessenger(to);

            from.Connect(KGB);
        }
Example #5
0
 public static void Connect(IMessenger from, IMessenger to)
 {
     from.Connect(ConnectUncleMajor(to));
 }
Example #6
0
 public static void Connect(IMessenger from, IMessenger to)
 {
     from.Connect(to);
 }
 public bool Connect()
 {
     return(messenger.Connect());
 }