35 lines
1.3 KiB
C
35 lines
1.3 KiB
C
#pragma once
|
|
#include "tlibc/errors.h"
|
|
#include "tlibc/string/str.h"
|
|
|
|
typedef struct Client Client;
|
|
|
|
Result(Client*) Client_create(str username, str password);
|
|
void Client_free(Client* client);
|
|
|
|
/// @return username saved during client initialization
|
|
str Client_getUserName(Client* client);
|
|
|
|
/// @return AES key calculated from password that can be used to encrypt user data
|
|
Array(u8) Client_getUserDataKey(Client* client);
|
|
|
|
/// @param server_addr_cstr ip:port
|
|
/// @param server_pk_base64 public key encoded by `RSA_serializePublicKey_base64()`
|
|
Result(void) Client_connect(Client* client, cstr server_addr_cstr, cstr server_pk_base64);
|
|
/// disconnect from current server
|
|
void Client_disconnect(Client* client);
|
|
|
|
/// @param self connected client
|
|
/// @param out_name owned by Client, fetched from server during Client_connect
|
|
Result(void) Client_getServerName(Client* self, str* out_name);
|
|
|
|
/// @param self connected client
|
|
/// @param out_name owned by Client, fetched from server during Client_connect
|
|
Result(void) Client_getServerDescription(Client* self, str* out_desc);
|
|
|
|
/// Create new account on connected server
|
|
Result(void) Client_register(Client* self, u64* out_user_id);
|
|
|
|
/// Authorize on connected server
|
|
Result(void) Client_login(Client* self, u64* out_user_id, u64* out_landing_channel_id);
|