swift
deletepilot.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "core/fsd/deletepilot.h"
5 
6 #include "misc/logmessage.h"
7 
8 using namespace swift::misc;
9 
10 namespace swift::core::fsd
11 {
12  DeletePilot::DeletePilot() : MessageBase() {}
13 
14  DeletePilot::DeletePilot(const QString &callsign, const QString &id) : MessageBase(callsign), m_cid(id) {}
15 
16  QStringList DeletePilot::toTokens() const
17  {
18  auto tokens = QStringList {};
19  tokens.push_back(m_sender);
20  tokens.push_back(m_cid);
21  return tokens;
22  }
23 
24  DeletePilot DeletePilot::fromTokens(const QStringList &tokens)
25  {
26  if (tokens.isEmpty())
27  {
28  CLogMessage(static_cast<DeletePilot *>(nullptr)).debug(u"Wrong number of arguments.");
29  return {};
30  }
31 
32  // VATSIM FSD will always supply the CERTIFICATE ID when it rebroadcasts this PDU without regard for whether
33  // the client originally specified it. But other FSDs might not.
34  DeletePilot packet(tokens[0], (tokens.size() >= 2) ? tokens[1] : "");
35  return packet;
36  }
37 } // namespace swift::core::fsd
Used to notify the server of the intention to close the connection. If a client receives this packet ...
Definition: deletepilot.h:16
QStringList toTokens() const
Message converted to tokens.
Definition: deletepilot.cpp:16
static DeletePilot fromTokens(const QStringList &tokens)
Construct from tokens.
Definition: deletepilot.cpp:24
FSD message base class.
Definition: messagebase.h:58
QString m_sender
message sender
Definition: messagebase.h:88
Class for emitting a log message.
Definition: logmessage.h:27
Derived & debug()
Set the severity to debug.
Free functions in swift::misc.