Blagovest Petrov
2 years ago
10 changed files with 72 additions and 42 deletions
@ -1,15 +0,0 @@ |
|||
#include "fetchshowid.h" |
|||
|
|||
FetchShowID::FetchShowID() |
|||
{ |
|||
n_manager = new QNetworkAccessManager; |
|||
|
|||
connect(n_manager, SIGNAL(finished(QNetworkReply*)), |
|||
this, SLOT(replyFinished(QNetworkReply*))); |
|||
|
|||
} |
|||
|
|||
|
|||
void FetchShowID::Fetch() { |
|||
n_manager->get(QNetworkRequest(QUrl("http://app.radiotangra.com/TMR_monitor_songs"))); |
|||
} |
@ -1,20 +0,0 @@ |
|||
#ifndef FETCHSHOWID_H |
|||
#define FETCHSHOWID_H |
|||
#include <QNetworkAccessManager> |
|||
#include <QNetworkReply> |
|||
#include <QObject> |
|||
#include <QDebug> |
|||
#include <QString> |
|||
|
|||
|
|||
class FetchShowID : public QObject |
|||
{ |
|||
public: |
|||
FetchShowID(); |
|||
void Fetch(); |
|||
|
|||
private: |
|||
QNetworkAccessManager* n_manager; |
|||
}; |
|||
|
|||
#endif // FETCHSHOWID_H
|
@ -0,0 +1,31 @@ |
|||
import QtQuick 2.0 |
|||
|
|||
Item { |
|||
property string theShow: "" |
|||
|
|||
function getShow(url) { |
|||
let request = new XMLHttpRequest() |
|||
|
|||
request.onreadystatechange = function () { |
|||
if (request.readyState === XMLHttpRequest.DONE) { |
|||
// let content = request.response.slice(0, request.response.indexOf("\n")); |
|||
let response = { |
|||
status : request.status, |
|||
headers : request.getAllResponseHeaders(), |
|||
content : request.response |
|||
}; |
|||
}; |
|||
theShow = request.responseText.toString().slice(0, request.response.indexOf("\n")); |
|||
} |
|||
|
|||
request.open("GET", "http://app.radiotangra.com/TMR_monitor_songs") |
|||
request.send() |
|||
} |
|||
|
|||
Timer { |
|||
interval: 30000 |
|||
running: true |
|||
repeat: true |
|||
onTriggered: getShow() |
|||
} |
|||
} |
Loading…
Reference in new issue