Is there a way to attach a compressed file here? It would be better if
i send you a VS solution.

Do you mind if i send you over email?


On 23 Aralık, 01:24, Kenton Varda <ken...@google.com> wrote:
> Sorry, I need an example which I can compile myself.  Can you write a small
> example program that has the same problem and send me the full source code
> so I can debug it?
>
> On Mon, Dec 22, 2008 at 2:58 PM, <ufukalti...@gmail.com> wrote:
>
> > Hello,
>
> > I'm using VS2008, here's the code:
>
> > //Math.Service.proto
>
> > package Math.Service;
>
> > option optimize_for = SPEED;
>
> > message MathBinaryOperationRequest {
> >    required float first = 1;
> >    required float second = 2;
> > }
>
> > message MathResponse {
> >    required float result = 1;
> > }
>
> > service Math {
> >    rpc Add( MathBinaryOperationRequest ) returns( MathResponse );
> >    rpc Multiply( MathBinaryOperationRequest ) returns
> > ( MathResponse );
> > }
>
> > // MathServiceServer.cpp
> > ....
> > MathService *service = new MathService();
> > RpcController* rpcCont;
>
> > MathServiceServer::MathServiceServer(ISocketHandler &h) : TcpSocket(h)
> > {
>
> > }
> > MathServiceServer::~MathServiceServer()
> > {
>
> > }
> > void MathServiceServer::OnRead()
> > {
> >        /**
> >         * Get the method name from socket buffer by parsing RPC message
> >         * Fill request with the encapsulated message inside RPC message
> >         * (I'm not including details on those...)
> >         */
>
> >        const MethodDescriptor* method = service->GetDescriptor()-
> > >FindMethodByName(methodName);
> >        rpcCont = new MathRpcController();
> >        Message* request = service->GetRequestPrototype(method).New();
> >        request->ParseFrom...(remainingSocketBuffer);
> >        Message* response = service->GetResponsePrototype(method).New();
> >        service->CallMethod(method, rpcCont, request, response, NewCallback
> > (this,&MathServiceServer::ServiceDone,response));
>
> > }
> > void MathServiceServer::OnAccept()
> > {
>
> > }
> > void MathServiceServer::ServiceDone(const Math::Service::MathResponse*
> > response)
> > {
>
> > }
> > ...
>
> > //MathService.cpp
>
> > ...
>
> > void MathService::Add(google::protobuf::RpcController* controller,
> > const Math::Service::MathBinaryOperationRequest* request,
> > Math::Service::MathResponse* response, google::protobuf::Closure*
> > done)
> > {
> >        float num1 = request->first();
> >        float num2 = request->second();
>
> >        float result = num1 + num2;
>
> >        response->set_result(result);
> >        done->Run();
> > }
> > void MathService::Multiply(google::protobuf::RpcController*
> > controller, const Math::Service::MathBinaryOperationRequest* request,
> > Math::Service::MathResponse* response, google::protobuf::Closure*
> > done)
> > {
> >        float num1 = request->first();
> >        float num2 = request->second();
>
> >        float result = num1 * num2;
>
> >        response->set_result(result);
> >        done->Run();
> > }
>
> > ...
>
> > Is there anything wrong with this code? I just followed the
> > documentation but it doesn't work.
>
> > I'll be more than glad if anyone can help me.
>
> > Thanks.
>
> > On Dec 22, 7:20 pm, Kenton Varda <ken...@google.com> wrote:
> > > I can't reproduce this problem.  What compiler are you using?  Can you
> > > provide example code which demonstrates the problem?
>
> > > On Mon, Dec 22, 2008 at 2:18 AM, <ufukalti...@gmail.com> wrote:
>
> > > > Btw, i'm using the latest svn version of the compiler and library
>
> > > > On Dec 20, 11:28 pm, ufukalti...@gmail.com wrote:
> > > > > Hello,
>
> > > > > I'm trying to implement a socket based RPC implementation with
> > > > > protobuf but i'm stuck at creating Closure.
>
> > > > > // Example that calls a method:
> > > > > //   class Handler {
> > > > > //    public:
> > > > > //     ...
> > > > > //
> > > > > //     void FooDone(const FooResponse* response) {
> > > > > //       ...
> > > > > //     }
> > > > > //
> > > > > //     void CallFoo() {
> > > > > //       ...
> > > > > //       // When done, call FooDone() and pass it a pointer to the
> > > > > response.
> > > > > //       Closure* callback = NewCallback(this, &Handler::FooDone,
> > > > > response);
> > > > > //       // Make the call.
> > > > > //       service->Foo(controller, request, response, callback);
> > > > > //     }
> > > > > //   };
>
> > > > > I'm following this example but it gives an error complaining about:
> > > > > "function does not take 3 arguments": NewCallback
>
> > > > > Can you please help me on this?
>
> > > > > Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to