Rewrite Node greeter example to use generated code
diff --git a/examples/node/greeter_server.js b/examples/node/greeter_server.js
index 47d9892..08ca600 100644
--- a/examples/node/greeter_server.js
+++ b/examples/node/greeter_server.js
@@ -31,16 +31,18 @@
*
*/
-var PROTO_PATH = __dirname + '/../protos/helloworld.proto';
-
var grpc = require('grpc');
-var hello_proto = grpc.load(PROTO_PATH).helloworld;
+
+var hello_messages = require('./helloworld_pb');
+var hello_service = require('./helloworld_grpc_pb');
/**
* Implements the SayHello RPC method.
*/
function sayHello(call, callback) {
- callback(null, {message: 'Hello ' + call.request.name});
+ var reply = new hello_messages.HelloReply();
+ reply.setMessage("Hello " + call.request.getName());
+ callback(null, reply);
}
/**
@@ -49,7 +51,7 @@
*/
function main() {
var server = new grpc.Server();
- server.addProtoService(hello_proto.Greeter.service, {sayHello: sayHello});
+ server.addService(hello_service.GreeterService, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}