Skip to content

How to instantiate Service? #507

@pronebird

Description

@pronebird

Hi,

I am following the example at https://github.com/dcodeIO/protobuf.js/wiki/Services and creating my RPC.

Everything seems fine but I cannot create a new instance of Service. it says:

Service is not a constructor

  var Service = root.lookup('MailService');
  var RequestType = root.lookup('RequestType');
  var ResponseType = root.lookup('ResponseType');

  function rpcHandler(method, req, callback) {
    var request = RequestType.decode(data);
    var response = new ResponseType();

    if(method === '.MailService.addMailbox') {
      // add mailbox
    } else if(method === '.MailService.removeMailbox') {
     // remove mailbox
    }

    callback(response.toBuffer());
  }

  var srv = new Service(rpcHandler); // CRASH

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions