#721·muduo

构建错误 !!

作者: gggggwen创建于 2025年3月6日更新于 2025年3月6日

#ifndef CHATSERVICE_H #define CHATSERVICE_H #include <muduo/net/TcpConnection.h> #include <unordered_map> #include using namespace std; using namespace muduo; using namespace muduo::net; #include "json.hpp" using json = nlohmann::json;

// The type of event callback method for processing messages using MsgHandler = std::function<void(const TcpConnectionPtr &conn, json &js, Timestamp)>;

// Chat server business class class ChatService { public: // Interface function for getting the instance object static ChatService *get_instance(); // Process the login business void login(const TcpConnectionPtr &conn, json &js, Timestamp time); // Process the registration business void reg(const TcpConnectionPtr &conn, json &js, Timestamp time); // Get the handler for the message MsgHandler getHandler(int msgid);

private: ChatService();

// Store the message id and its corresponding business processing method
std::unordered_map<int, MsgHandler> msgHandlerMap_;

#endif