♻️ Remove duplicate ping pong handling
This commit is contained in:
@@ -110,35 +110,21 @@ class CommAdapterBase {
|
|||||||
}
|
}
|
||||||
case message_type_t::PING: {
|
case message_type_t::PING: {
|
||||||
ESP_LOGI("Comm Base", "PING (cid=%d)", cid);
|
ESP_LOGI("Comm Base", "PING (cid=%d)", cid);
|
||||||
#if USE_MSGPACK
|
ping(cid);
|
||||||
static const uint8_t pong[] = {0x91, 0x04};
|
|
||||||
send(pong, sizeof(pong), cid);
|
|
||||||
#else
|
|
||||||
send("[4]", cid);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case message_type_t::PONG: ESP_LOGI("Comm Base", "PONG (cid=%d)", cid); break;
|
case message_type_t::PONG: ESP_LOGI("Comm Base", "PONG (cid=%d)", cid); break;
|
||||||
default: ESP_LOGW("Comm Base", "Unknown message type: %d", static_cast<int>(type)); break;
|
default: ESP_LOGW("Comm Base", "Unknown message type: %d", static_cast<int>(type)); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == PONG) {
|
|
||||||
ESP_LOGV("EventSocket", "Pong");
|
|
||||||
return;
|
|
||||||
} else if (type == PING) {
|
|
||||||
ESP_LOGV("EventSocket", "Ping");
|
|
||||||
ping(cid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ping(int cid) {
|
void ping(int cid) {
|
||||||
#if USE_MSGPACK
|
#if USE_MSGPACK
|
||||||
const uint8_t out[] = {0x91, 0x04};
|
static const uint8_t pong[] = {0x91, 0x04};
|
||||||
send(out, sizeof(out), cid);
|
send(pong, sizeof(pong), cid);
|
||||||
#else
|
#else
|
||||||
const char *out = "[4]";
|
send("[4]", cid);
|
||||||
send(out, strlen(out), cid);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user