Ejemplo n.º 1
0
        public async Task <IActionResult> Index(string theme, string Message, string username, string password)
        {
            MQTTClient    mq     = new MQTTClient(_config);
            List <string> topics = new List <string>();

            topics.Add("test1");
            mq.ConnectAsync(_ip, "svin", "123", topics);
            new Thread(() =>
            {
                mq.Reconnect(topics);
            }).Start();
            mq.PublisherAsync("test1");
            new Thread(async() =>
            {
                await foreach (var m in mq.Receive())
                {
                    mq.Save(m);
                }
            }).Start();

            Thread.Sleep(3000);
            var    recData = SignalsRepository.FindAll();
            string result  = null;

            foreach (var t in recData)
            {
                result += t.Name + ' ' + t.Data + ' ' + t.Time + ' ' + t.Quality + "/n";
            }
            return(Content(result));
        }