myxlib/examples/redis/01_client/client.hpp

33 lines
545 B
C++
Raw Normal View History

#include <QObject>
#include <QDebug>
#include <myx/redis/pubsub.hpp>
namespace MR = myx::redis;
class RedisClient : public QObject
{
Q_OBJECT
public:
explicit RedisClient( MR::PubSub* p, QObject* o = nullptr ) :
QObject( o )
{
p->subscribe( "test", this, "readChannelTest" );
}
private:
Q_INVOKABLE void readChannelTest( const QString& channel, const QByteArray& message )
{
qDebug() << channel;
qDebug() << message;
if ( message == "quit" )
{
qCritical() << message;
qApp->quit();
}
}
}; // class RedisClient