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