61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
//
|
|
// Created by dongl on 23-5-10.
|
|
//
|
|
|
|
#ifndef IM2_USEROPERATION_H
|
|
#define IM2_USEROPERATION_H
|
|
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
#include "event2/bufferevent.h"
|
|
#include "core/Client.h"
|
|
#include "MP/Request.h"
|
|
#include "core/management.h"
|
|
|
|
|
|
#define LOGIN_ACCOUNT mp::MP_LOGIN_ACCOUNT
|
|
#define LOGIN_PHONE mp::MP_LOGIN_PHONE
|
|
#define LOGIN_EMAIL mp::MP_LOGIN_EMAIL
|
|
|
|
#define REGISTER_EMAIL mp::MP_SUB_TYPE::MP_REGISTER_EMAIL
|
|
#define REGISTER_PHONE mp::MP_SUB_TYPE::MP_REGISTER_PHONE
|
|
|
|
|
|
class UserOperation {
|
|
public:
|
|
explicit UserOperation(Client* client);
|
|
virtual ~UserOperation();
|
|
|
|
public:
|
|
// 登陆
|
|
std::optional<agreement_response> login(const std::string& account, const std::string& password);
|
|
// 注册
|
|
std::optional<agreement_response> register_(const std::string& account, const std::string& password, const std::string& code);
|
|
// 请求验证码
|
|
std::optional<agreement_response> get_code(const std::string& account);
|
|
// 查询账户好友
|
|
std::optional<agreement_response> fetch_friends(uint64_t account);
|
|
// 查询用户 并 查看是否已为好友
|
|
std::optional<agreement_response> fetch_user(uint64_t user, uint64_t account);
|
|
// 添加用户 account 本机账户 带添加账户
|
|
std::optional<agreement_response> add_user(uint64_t account, uint64_t user);
|
|
|
|
private:
|
|
// base 包
|
|
std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password);
|
|
std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password, const std::string &data);
|
|
std::string packet_base(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, const std::string& account);
|
|
std::string packet_base(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, uint64_t source, uint64_t target);
|
|
|
|
|
|
// 操作报
|
|
std::string login_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password);
|
|
std::string register_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password, const std::string &code);
|
|
private:
|
|
Client* client;
|
|
};
|
|
|
|
|
|
#endif //IM2_USEROPERATION_H
|