Esempio n. 1
0
        // Entry point from C++.
        static internal void ProtoRpcBegin(
            RcfProtoServer self,
            RcfProtoSession session,
            string serviceName,
            int methodId)
        {
            int requestBufferLen = session._GetRequestBufferLength();

            byte[] requestBuffer = new byte[requestBufferLen];
            session._GetRequestBuffer(requestBuffer, requestBuffer.Length);

            // Look up the service and method.
            Google.ProtocolBuffers.IService service = null;
            if (self.mPbServices.ContainsKey(serviceName))
            {
                service = self.mPbServices[serviceName];
            }

            if (service == null)
            {
                string errorMsg = "The requested service does not exist on this server. Service name: " + serviceName;
                throw new Exception(errorMsg);
            }

            ServiceDescriptor serviceDesc = service.DescriptorForType;
            MethodDescriptor  methodDesc  = serviceDesc.Methods[methodId];

            // Build the request object.
            IMessage   requestPrototype = service.GetRequestPrototype(methodDesc);
            IBuilder   builder          = requestPrototype.WeakCreateBuilderForType();
            ByteString byteString       = ByteString.CopyFrom(requestBuffer);

            builder.WeakMergeFrom(byteString);
            IMessage request = builder.WeakBuild();

            // Call the PB service
            // "=>" not supported in .NET 2.0.
            //Action<IMessage> done = (IMessage msg) => ProtoRpcEndCs(session, msg);
            Action <IMessage> done = delegate(IMessage msg) { ProtoRpcEndCs(self, session, msg); };

            RcfProtoController controller = new RcfProtoController(session);

            service.CallMethod(methodDesc, controller, request, done);
        }
Esempio n. 2
0
 static internal void BindService(
     RcfProtoServer self,
     Google.ProtocolBuffers.IService svc)
 {
     self.mPbServices.Add(svc.DescriptorForType.Name, svc);
 }