#include "message.h"
#include "util.h"
-#include "signalproxy.h"
#include "peer.h"
+#include "signalproxy.h"
#include <QDataStream>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef PEER_H
-#define PEER_H
+#pragma once
#include <QAbstractSocket>
#include <QDataStream>
#include "authhandler.h"
#include "protocol.h"
-#include "signalproxy.h"
#include "quassel.h"
+#include "signalproxy.h"
class Peer : public QObject
{
return;
}
}
-
-#endif
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef PROTOCOL_H_
-#define PROTOCOL_H_
+#pragma once
#include <QByteArray>
#include <QDateTime>
struct RegisterClient : public HandshakeMessage
{
- inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, int32_t features = 0)
+ inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, quint32 features = 0)
: clientVersion(clientVersion)
, buildDate(buildDate)
, sslSupported(sslSupported)
// this is only used by the LegacyProtocol in compat mode
bool sslSupported;
- int32_t clientFeatures;
+ quint32 clientFeatures;
};
};
-
-#endif
processMessage(msg);
-
if (SignalProxy::current())
SignalProxy::current()->setSourcePeer(nullptr);
}
// ==================================================
// SignalProxy
// ==================================================
+
+thread_local SignalProxy *SignalProxy::_current{nullptr};
+
SignalProxy::SignalProxy(QObject *parent)
: QObject(parent)
{
_syncSlave.clear();
removeAllPeers();
+
+ _current = nullptr;
}
initClient();
}
-thread_local SignalProxy *SignalProxy::_current;
-
-
void SignalProxy::init()
{
_heartBeatInterval = 0;
template<class T>
void SignalProxy::dispatch(const T &protoMessage)
{
- for (auto peer : _peerMap.values()) {
- _targetPeer = peer;
-
- if (peer->isOpen())
- peer->dispatch(protoMessage);
- else
- QCoreApplication::postEvent(this, new ::RemovePeerEvent(peer));
+ for (auto&& peer : _peerMap.values()) {
+ dispatch(peer, protoMessage);
}
- _targetPeer = nullptr;
}
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef SIGNALPROXY_H
-#define SIGNALPROXY_H
+#pragma once
#include <QEvent>
#include <QSet>
-#include <QThreadStorage>
#include <functional>
-#include <memory>
+#include <initializer_list>
#include "protocol.h"
QHash<QByteArray, int> _methodIds;
QHash<int, int> _receiveMap; // if slot x is called then hand over the result to slot y
};
-
-#endif