File indexing completed on 2024-05-12 05:40:55
0001 #include "network/upnp/upnpnat.h" 0002 #include <QCoreApplication> 0003 #include <QDebug> 0004 #include <QFile> 0005 0006 int main(int argc, char* argv[]) 0007 { 0008 QCoreApplication app(argc, argv); 0009 UpnpNat nat; 0010 0011 nat.init(5, 10); 0012 QObject::connect(&nat, &UpnpNat::discoveryEnd, [&nat](bool b) { 0013 if(b) 0014 nat.addPortMapping("upnpRolisteam", nat.localIp(), 6664, 6664, "TCP"); 0015 // qDebug() << "Discovery END:"<<b; 0016 }); 0017 QObject::connect(&nat, &UpnpNat::statusChanged, [&nat, &app]() { 0018 if(nat.status() == UpnpNat::NAT_STAT::NAT_ADD) 0019 { 0020 qDebug() << "It worked!"; 0021 app.quit(); 0022 } 0023 }); 0024 0025 QObject::connect(&nat, &UpnpNat::lastErrorChanged, [&nat]() { qDebug() << " Error:" << nat.lastError(); }); 0026 0027 nat.discovery(); 0028 0029 return app.exec(); 0030 }