Files
IM/MS/mmm/mapping.cpp
dongl ba80c3954d 0510 15:15 gtest邮件可发送 创建session类 记录全局链接会话 时间轮记录session超时。
邮件验证码 可以发送 c端test 没写  验证验证码注册还未完成
2023-05-10 16:07:31 +08:00

48 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by dongl on 23-4-23.
//
#include "mapping.h"
#include "SimpleIni.h"
#include "EnumMapping.h"
#include <fstream>
std::map<mp::MP_TYPE, handler*> mapping::map;
mapping::mapping() {
if (map.empty()) {
// CSimpleIniA ini;
// ini.SetUnicode();
// ini.LoadFile("/home/dongl/code/网络编程/IMS/config/db.ini");
// auto key_value = ini.GetSection("server-mapping");
// 用户验证证明
auto userProve = new UserProveController();
map.insert( std::pair<mp::MP_TYPE, handler*>(mp::MP_REQUEST_LOGIN, userProve));
map.insert( std::pair<mp::MP_TYPE, handler*>(mp::MP_REQUEST_REGISTER, userProve));
map.insert( std::pair<mp::MP_TYPE, handler*>(mp::MP_REQUEST_LOGOUT, userProve));
// 验证码
auto peVerifCode = new PEVerifCodeController();
map.insert( std::pair<mp::MP_TYPE, handler*>(mp::MP_REQUEST_PE_CODE, peVerifCode));
// 用户添加好友群组类操作
auto improve = new IMProveController();
map.insert({mp::MP_REQUEST_IM_ADD, improve});
}
}
void mapping::run(const mp::MP_TYPE mpTYpe, std::shared_ptr<agreement_request>& request, std::shared_ptr<agreement_response>& response) {
mapping();
printf("[packet type]%s\n", myenumToString(mpTYpe));
// 取出需要的执行对象
auto fun = map.find(mpTYpe)->second;
// 开始执行 请求
fun->run(request, response);
// 发送 响应
handler::resp(request, response);
}