swift
ping.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/ping.h"
5 
6 #include "misc/logmessage.h"
7 
8 namespace swift::core::fsd
9 {
10  Ping::Ping(const QString &sender, const QString &receiver, const QString &timestamp)
11  : MessageBase(sender, receiver), m_timestamp(timestamp)
12  {}
13 
15  {
16  QStringList tokens;
17  tokens.push_back(m_sender);
18  tokens.push_back(m_receiver);
19  tokens.push_back(m_timestamp);
20  return tokens;
21  }
22 
24  {
25  if (tokens.size() < 3)
26  {
27  swift::misc::CLogMessage(static_cast<Ping *>(nullptr)).debug(u"Wrong number of arguments.");
28  return {};
29  };
30  return { tokens[0], tokens[1], tokens[2] };
31  }
32 } // namespace swift::core::fsd
FSD message base class.
Definition: messagebase.h:58
QString m_receiver
message receiver
Definition: messagebase.h:89
QString m_sender
message sender
Definition: messagebase.h:88
Ping. Needs to be answered with a pong.
Definition: ping.h:15
QString m_timestamp
timestamp
Definition: ping.h:29
QStringList toTokens() const
Message converted to tokens.
Definition: ping.cpp:14
static Ping fromTokens(const QStringList &tokens)
Construct from tokens.
Definition: ping.cpp:23
Class for emitting a log message.
Definition: logmessage.h:27
Derived & debug()
Set the severity to debug.
void push_back(QList< T >::parameter_type value)
qsizetype size() const const