mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-07-12 18:03:52 +00:00
@@ -7,11 +7,9 @@ ComputerSeeker::ComputerSeeker(ComputerManager *manager, QString computerName, Q
|
|||||||
m_TimeoutTimer(new QTimer(this))
|
m_TimeoutTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
// If we know this computer, send a WOL packet to wake it up in case it is asleep.
|
// If we know this computer, send a WOL packet to wake it up in case it is asleep.
|
||||||
const auto computers = m_ComputerManager->getComputers();
|
NvComputer* matchingComputer = findMatchingComputer();
|
||||||
for (NvComputer* computer : computers) {
|
if (matchingComputer) {
|
||||||
if (this->matchComputer(computer)) {
|
matchingComputer->wake();
|
||||||
computer->wake();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_TimeoutTimer->setSingleShot(true);
|
m_TimeoutTimer->setSingleShot(true);
|
||||||
@@ -24,11 +22,16 @@ ComputerSeeker::ComputerSeeker(ComputerManager *manager, QString computerName, Q
|
|||||||
void ComputerSeeker::start(int timeout)
|
void ComputerSeeker::start(int timeout)
|
||||||
{
|
{
|
||||||
m_TimeoutTimer->start(timeout);
|
m_TimeoutTimer->start(timeout);
|
||||||
// Seek desired computer by both connecting to it directly (this may fail
|
|
||||||
// if m_ComputerName is UUID, or the name that doesn't resolve to an IP
|
// If we don't know this computer by name, address, or UUID, try adding it
|
||||||
// address) and by polling it using mDNS, hopefully one of these methods
|
// manually and see if we can find it by address, hostname, or mDNS.
|
||||||
// would find the host
|
//
|
||||||
m_ComputerManager->addNewHostManually(m_ComputerName);
|
// NB: We don't do this unconditionally because it will wipe out the user's
|
||||||
|
// manual address if they pass another reachable hostname/address.
|
||||||
|
if (!findMatchingComputer()) {
|
||||||
|
m_ComputerManager->addNewHostManually(m_ComputerName);
|
||||||
|
}
|
||||||
|
|
||||||
m_ComputerManager->startPolling();
|
m_ComputerManager->startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +65,18 @@ bool ComputerSeeker::matchComputer(NvComputer *computer) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NvComputer* ComputerSeeker::findMatchingComputer() const
|
||||||
|
{
|
||||||
|
const auto computers = m_ComputerManager->getComputers();
|
||||||
|
for (NvComputer* computer : computers) {
|
||||||
|
if (this->matchComputer(computer)) {
|
||||||
|
return computer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool ComputerSeeker::isOnline(NvComputer *computer) const
|
bool ComputerSeeker::isOnline(NvComputer *computer) const
|
||||||
{
|
{
|
||||||
return computer->state == NvComputer::CS_ONLINE;
|
return computer->state == NvComputer::CS_ONLINE;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool matchComputer(NvComputer *computer) const;
|
bool matchComputer(NvComputer *computer) const;
|
||||||
|
NvComputer* findMatchingComputer() const;
|
||||||
bool isOnline(NvComputer *computer) const;
|
bool isOnline(NvComputer *computer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user