Esempio n. 1
0
        public Device(bool log, string deviceNameIn)
        {
            DeviceName = deviceNameIn;
            logger     = new Log.Logger(log);
            logger.SetCallback(Console.WriteLine);
            logger.Log("Initializing...");
            taskList                 = new TasksToCancel();
            DeviceListener           = new DeviceListener();
            DeviceCommunication      = new DeviceCommunication(logger);
            DeviceEurekaInfoListener = new DeviceEurekaInfoListener();
            MdnsAdvertise            = new MdnsAdvertise(logger, DeviceName);
            MdnsAdvertise.Advertise();
            ipAddress = Network.GetIp4Address();
            if (ipAddress == null)
            {
                logger.Log(Strings.Message_NoIPAddress);
                return;
            }

            StartTask(() =>
            {
                DeviceListener.StartListening(ipAddress, 8009, OnReceive, logger);
            });
            StartTask(() =>
            {
                DeviceEurekaInfoListener.StartListening(ipAddress, 8008, OnReceiveEureka, logger);
            });
            StartTask(() =>
            {
                new VolumeHook().Start(this);
            });
        }
Esempio n. 2
0
 public void SendNewVolume(float level)
 {
     DeviceCommunication.SendNewVolume(level, DeviceListener);
 }
Esempio n. 3
0
 private void OnReceive(CastMessage message)
 {
     logger.Log($"in [{DateTime.Now.ToLongTimeString()}] [{ipAddress}:8009]: {message.PayloadUtf8}");
     DeviceCommunication.ProcessMessage(DeviceListener, message);
 }