mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-19 20:16:15 +02:00
controller
git-svn-id: svn://elaine/murooma/trunk@120 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
d43298f0fe
commit
6e8cac955f
3 changed files with 117 additions and 35 deletions
|
@ -3,32 +3,45 @@
|
|||
//
|
||||
// Olivier Chamoux <olivier.chamoux@fr.thalesgroup.com>
|
||||
|
||||
#include <thread>
|
||||
#include <istream>
|
||||
#include "zhelpers.hpp"
|
||||
|
||||
#define NBR_WORKERS 10
|
||||
|
||||
|
||||
void receiver(zmq::socket_t* client)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
std::string address = s_recv (*client);
|
||||
std::cout << "Address: " << address << "\n";
|
||||
// receiving and discarding'empty' message
|
||||
s_recv (*client);
|
||||
// receiving and discarding 'ready' message
|
||||
std::string msg = s_recv (*client);
|
||||
std::cout << "msg: " << msg << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main () {
|
||||
zmq::context_t context(2);
|
||||
zmq::socket_t client (context, ZMQ_ROUTER);
|
||||
client.bind("tcp://127.0.0.1:10000");
|
||||
client.bind("tcp://0.0.0.0:123459");
|
||||
|
||||
std::thread receiveThread(receiver, &client);
|
||||
|
||||
int task_nbr;
|
||||
while (true)
|
||||
{
|
||||
// LRU worker is next waiting in queue
|
||||
std::string address = s_recv (client);
|
||||
std::cout << "Address: " << address << "\n";
|
||||
|
||||
// receiving and discarding'empty' message
|
||||
s_recv (client);
|
||||
// receiving and discarding 'ready' message
|
||||
std::string msg = s_recv (client);
|
||||
std::cout << "msg: " << msg << "\n";
|
||||
std::string address;
|
||||
std::string cmd;
|
||||
|
||||
std::getline(std::cin, address);
|
||||
std::getline(std::cin, cmd);
|
||||
s_sendmore (client, address);
|
||||
s_sendmore (client, "");
|
||||
s_send (client, std::string("hello: ") + address);
|
||||
s_send (client, cmd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue