21 #include <QStringList>
29 #include "libmythbase/mythversion.h"
47 Task(
"UPnpNotifyTask"),
48 m_nServicePort(nServicePort)
63 if ( sUDN.length() > 0)
64 sUSN = sUDN +
"::" + sNT;
68 QString sData = QString (
"Server: %1\r\n"
72 "CACHE-CONTROL: max-age=%6\r\n"
73 "Content-Length: 0\r\n\r\n" )
80 LOG(VB_UPNP, LOG_INFO,
81 QString(
"UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
82 .arg(pSocket->address().toString(), QString::number(pSocket->port()),
93 for (
const auto & addr : std::as_const(addressList))
95 if (addr.toString().isEmpty())
97 LOG(VB_GENERAL, LOG_ERR,
98 "UPnpNotifyTask::SendNotifyMsg - NULL in address list");
102 QHostAddress ip = addr;
106 ip.setScopeId(QString());
108 QString ipaddress = ip.toString();
111 if (ipaddress.contains(
":"))
112 ipaddress =
"[" + ipaddress +
"]";
114 QString sHeader = QString(
"NOTIFY * HTTP/1.1\r\n"
116 "LOCATION: http://%3:%4/getDeviceDesc\r\n")
117 .arg(pSocket->address().toString()) .arg(pSocket->port())
120 QString sPacket = sHeader + sData;
121 QByteArray scPacket = sPacket.toUtf8();
127 pSocket->writeBlock( scPacket, scPacket.length(),
128 pSocket->address(), pSocket->port() );
131 std::this_thread::sleep_for(std::chrono::milliseconds(
MythRandom(0, 250)));
133 pSocket->writeBlock( scPacket, scPacket.length(),
134 pSocket->address(), pSocket->port() );
168 pMulticast =
nullptr;
207 for (
const auto & dev : std::as_const(pDevice->
m_listDevices))