2025-01-21 16:35:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "abstract_dispatcher.hpp"
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <google/protobuf/message.h>
|
|
|
|
#include <google/protobuf/service.h>
|
|
|
|
#include <google/protobuf/descriptor.h>
|
|
|
|
|
|
|
|
namespace tinyrpc {
|
|
|
|
|
|
|
|
class TinypbDispatcher : public AbstractDispatcher {
|
|
|
|
using Service = google::protobuf::Service;
|
2025-01-22 17:58:45 +08:00
|
|
|
using Method = google::protobuf::MethodDescriptor;
|
|
|
|
using Message = google::protobuf::Message;
|
2025-01-21 16:35:26 +08:00
|
|
|
public:
|
|
|
|
TinypbDispatcher();
|
|
|
|
~TinypbDispatcher();
|
|
|
|
void dispatcher(TcpConnection& conn, AbstractData& data, AbstractData& respond) override;
|
|
|
|
bool parseServiceFullName(const std::string& name, std::string& serviceName, std::string& methodName);
|
|
|
|
private:
|
|
|
|
std::unordered_map<std::string, Service*> m_service_map;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|