From 4f5cbb5e25cbb7c8624cb135760be8285ef00af8 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@d8a302eb-03bc-478d-80e4-98257eca68ef> Date: Fri, 1 Aug 2014 17:05:27 +0000 Subject: [PATCH] xxx git-svn-id: svn://elaine/murooma/trunk@128 d8a302eb-03bc-478d-80e4-98257eca68ef --- rtrClient.cpp | 16 +++++++++++++--- stream.cpp | 8 ++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/rtrClient.cpp b/rtrClient.cpp index 8f79e39b..8894165b 100644 --- a/rtrClient.cpp +++ b/rtrClient.cpp @@ -22,8 +22,16 @@ using namespace std; void alive(zmq::socket_t* worker) { // Tell the router we're ready for work + zmq::message_t message; while (1) { s_send (*worker, "ping"); + int res = worker->recv(&message); + if (res == 0) + { + std::string recvMsg = std::string(static_cast(message.data()), message.size()); + } + else + cout << "Error: " << res << "\n"; sleep(1); } } @@ -32,7 +40,7 @@ void alive(zmq::socket_t* worker) void control(zmq::socket_t* worker) { // Tell the router we're ready for work -// s_send (*worker, "ready"); + s_send (*worker, "ready"); while (1) { std::string cmd = s_recv (*worker); vector splitCmd = split(cmd); @@ -46,14 +54,16 @@ void control(zmq::socket_t* worker) int main () { cout << getMacAddress() << "\n"; zmq::context_t context(1); - zmq::socket_t worker (context, ZMQ_DEALER); + zmq::socket_t worker (context, ZMQ_REQ); srand (time(NULL)); // We use a string identity for ease here string macAddress = getMacAddress(); worker.setsockopt(ZMQ_IDENTITY, macAddress.c_str(), macAddress.length()); +// int timeout = 1000; +// worker.setsockopt(ZMQ_RCVTIMEO, &timeout, sizeof(timeout)); worker.connect("tcp://127.0.0.1:123459"); - std::thread controlThread(control, &worker); +// std::thread controlThread(control, &worker); std::thread aliveThread(alive, &worker); controlThread.join(); return 0; diff --git a/stream.cpp b/stream.cpp index ce275d69..dfe746da 100644 --- a/stream.cpp +++ b/stream.cpp @@ -77,7 +77,7 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction) } else { - int idx(chunk->idx); +/* int idx(chunk->idx); for (size_t n=0; npayload[idx]; @@ -97,8 +97,8 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction) } } chunk->idx = idx; - -/* size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE; +*/ + size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE; if (chunk->idx + PLAYER_CHUNK_SIZE > WIRE_CHUNK_SIZE) { if (outputBuffer != NULL) @@ -118,7 +118,7 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction) chunks.pop_front(); delete chunk; } -*/ + } return tv;