33 lines
872 B
C++
33 lines
872 B
C++
#include "init.h"
|
|
#include "global_vars.h"
|
|
#include "ssl.h"
|
|
#include "tcp.h"
|
|
#include "types.h"
|
|
#include <openssl/ssl.h>
|
|
|
|
void (*receive_callback)(std::vector<user>, std::string) = nullptr;
|
|
SSL_CTX *ctx_global = nullptr;
|
|
SSL *ssl_global = nullptr;
|
|
int sockfd_global = -1;
|
|
|
|
namespace pupes_message_client_lib {
|
|
|
|
void init(const char *hostname, const char *port) {
|
|
OpenSSL_add_all_algorithms();
|
|
|
|
ctx_global = pupes_message_client_lib::InitTLS();
|
|
|
|
sockfd_global =
|
|
pupes_message_client_lib::create_socket_and_connect(hostname, port);
|
|
|
|
ssl_global =
|
|
pupes_message_client_lib::TLS_handshake(ctx_global, sockfd_global);
|
|
}
|
|
|
|
void register_receive_callback(void (*callback)(std::vector<user>,
|
|
std::string)) {
|
|
receive_callback = callback;
|
|
}
|
|
|
|
void start_message_listener() {}
|
|
} // namespace pupes_message_client_lib
|