35 lines
749 B
C++
35 lines
749 B
C++
#include "../common/defines.h"
|
|
#include "global_vars.h"
|
|
#include <nlohmann/json.hpp>
|
|
#include <openssl/ssl.h>
|
|
|
|
using nlohmann::json;
|
|
|
|
namespace pupes_message_client_lib {
|
|
void message_listener() {
|
|
char buffer[BUFFER_SIZE];
|
|
int bytes_read;
|
|
|
|
while (1) {
|
|
bytes_read = SSL_read(ssl_global, buffer, BUFFER_SIZE);
|
|
|
|
if (bytes_read > 0) {
|
|
json message =
|
|
json::parse(std::string(buffer, static_cast<size_t>(bytes_read)));
|
|
|
|
switch (message["type"].get<uint8_t>()) {
|
|
case CHALLENGE: {
|
|
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
int err = SSL_get_error(ssl_global, bytes_read);
|
|
if (err == SSL_ERROR_WANT_READ)
|
|
continue;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} // namespace pupes_message_client_lib
|