tinyrpc/includes/net/tinypb/tinypb_dispatcher.hpp

29 lines
901 B
C++

#pragma once
#include "abstract_dispatcher.hpp"
#include <memory>
#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;
using Method = google::protobuf::MethodDescriptor;
using Message = google::protobuf::Message;
public:
TinypbDispatcher();
~TinypbDispatcher();
void dispatcher(ServerTcpConnection& conn, AbstractData& data, AbstractData& respond) override;
bool parseServiceFullName(const std::string& name, std::string& serviceName, std::string& methodName);
void registerService(std::shared_ptr<Service>& service);
private:
std::unordered_map<std::string, std::shared_ptr<Service>> m_service_map;
};
}