Commit 5068cb29 authored by Gabriel Margiani's avatar Gabriel Margiani

Allow heartbeat ok between commands and use it in event client.

parent a4298e71
......@@ -206,7 +206,13 @@ bool p3::client::push_event_manager() {
bool p3::client::push_event_reader() {
bool okexit = false;
while (true) {
p3::mQueueMessage m = connection->receive(-1);
p3::mQueueMessage m(p3::protocol::ERROR, "");
try {
m = connection->receive(200);
} catch (p3::perror & e) { // maybe we need a heartbeat
connection->send(p3::protocol::OK, "Heartbeat");
continue;
}
bool print_list = true;
switch (m.get_command()) {
case p3::protocol::BEGINTEXT:
......@@ -218,6 +224,7 @@ bool p3::client::push_event_reader() {
m = connection->receive(30);
}
std::cout << "---" << std::endl;
connection->send(p3::protocol::OK, "Event ok");
break;
case p3::protocol::OK:
if (verbose >= 1) std::cout << m.get_value() << std::endl;
......
......@@ -51,7 +51,7 @@ void print_usage() {
<< "p3 m ute [id] - mute ringtone if ringing, else mute microphone" << std::endl
<< "p3 ma muteall - mute microphone for all calls." << std::endl
<< "p3 j oin - conference current calls" << std::endl
<< "p3 t ransfer [id] [nr] - forward call" << std::endl
<< "p3 t ransfer [id] [id] - forward call" << std::endl
<< "p3 d tmf [dgts] [id] - dial dtfm digits" << std::endl
<< "p3 st atus - dump server status" << std::endl
<< "p3 e vents - Toggle push events" << std::endl
......
......@@ -154,6 +154,8 @@ void p3::clientHandler::run() {
case p3::protocol::SET_TIMEOUT:
listenTimeout = std::stoi(m.get_value());
break;
case p3::protocol::OK: // Heartbeat.
break;
case p3::protocol::QUIT:
case p3::protocol::BYE:
r = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment