void RcfProtoServer::ProtoRpcBeginCpp( RcfProtoSession & rcfProtoSession, const std::string & serviceName, int methodId) { RcfProtoControllerPtr controller( new RcfProtoController(rcfProtoSession) ); Service * pService = NULL; ProtobufServices::iterator iter = mProtobufServices.find(serviceName); if (iter != mProtobufServices.end()) { pService = iter->second; } if (!pService) { std::string errorMsg = "The requested service does not exist on this server. Service name: " + serviceName; controller->SetFailed(errorMsg); return; } const ServiceDescriptor * sd = pService->GetDescriptor(); const MethodDescriptor * md = sd->method(methodId); MessagePtr requestPtr( pService->GetRequestPrototype(md).New() ); MessagePtr responsePtr( pService->GetResponsePrototype(md).New() ); RCF::ByteBuffer requestBuffer = controller->mpRcfSession->mRequestBuffer; requestPtr->ParseFromArray(requestBuffer.getPtr(), (int) requestBuffer.getLength()); std::pair<MessagePtr, MessagePtr> requestResponsePair(requestPtr, responsePtr); Closure * done = NewCallback(this, &RcfProtoServer::ProtoRpcEndCpp, requestResponsePair, controller); pService->CallMethod(md, controller.get(), requestPtr.get(), responsePtr.get(), done); }
void RcfProtoServer::bindService(Service & service) { mProtobufServices[service.GetDescriptor()->name()] = &service; }