Example #1
0
void LxMQApp::start()
{
	QStringList args = QCoreApplication::arguments();
	if(args.size() < 3) 
	{
		qWarning() << "Usage: " << args.front() << " client|server <key>";
		QCoreApplication::exit();
		return;
	}

	m_byteKey = args.at(2).toLocal8Bit();

	QTimer *ndyt = new QTimer(this);
	connect(ndyt, SIGNAL(timeout()), this, SLOT(ndy()));
	ndyt->setInterval(5000);
	ndyt->start();

	if(args.at(1) == "client") 
	{
		m_pSocket = new ZmqSocket(ZMQ_SUB, this);
		connect(m_pSocket, SIGNAL(readyRead()), this, SLOT(heard()));
		m_pSocket->subscribe(m_byteKey);
		m_pSocket->connectTo("tcp://127.0.0.1:3782");
	}

	if(args.at(1) == "server") 
	{
		m_pSocket = new ZmqSocket(ZMQ_PUB, this);
		m_pSocket->bind("tcp://127.0.0.1:3782");
		QTimer *t = new QTimer(this);
		connect(t, SIGNAL(timeout()), this, SLOT(squawk()));
		t->setInterval(1000);
		t->start();
	}
}
 Foo::Foo(const void *inVoid) {
   squawk();
 }
 Base() { squawk(); }