Updated Node examples to be compatible with master

pull/3143/head
murgatroid99 10 years ago
parent cf08a881fb
commit c919228e0a
  1. 3
      examples/node/greeter_client.js
  2. 14
      examples/node/greeter_server.js
  3. 2
      examples/node/package.json
  4. 3
      examples/node/route_guide/route_guide_client.js
  5. 20
      examples/node/route_guide/route_guide_server.js

@ -37,7 +37,8 @@ var grpc = require('grpc');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
function main() {
var client = new hello_proto.Greeter('localhost:50051');
var client = new hello_proto.Greeter('localhost:50051',
grpc.Credentials.createInsecure());
var user;
if (process.argv.length >= 3) {
user = process.argv[2];

@ -36,8 +36,6 @@ var PROTO_PATH = __dirname + '/helloworld.proto';
var grpc = require('grpc');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
var Server = grpc.buildServer([hello_proto.Greeter.service]);
/**
* Implements the SayHello RPC method.
*/
@ -50,14 +48,10 @@ function sayHello(call, callback) {
* sample server port
*/
function main() {
var server = new Server({
"helloworld.Greeter": {
sayHello: sayHello
}
});
server.bind('0.0.0.0:50051');
server.listen();
var server = new grpc.Server();
server.addProtoService(hello_proto.Greeter.service, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}
main();

@ -3,7 +3,7 @@
"version": "0.5.0",
"dependencies": {
"async": "^0.9.0",
"grpc": "~0.9.0",
"grpc": "~0.11.0",
"minimist": "^1.1.0",
"underscore": "^1.8.2"
}

@ -34,7 +34,8 @@ var path = require('path');
var _ = require('underscore');
var grpc = require('grpc');
var examples = grpc.load(__dirname + '/route_guide.proto').examples;
var client = new examples.RouteGuide('localhost:50051');
var client = new examples.RouteGuide('localhost:50051',
grpc.Credentials.createInsecure());
var COORD_FACTOR = 1e7;

@ -34,8 +34,6 @@ var _ = require('underscore');
var grpc = require('grpc');
var examples = grpc.load(__dirname + '/route_guide.proto').examples;
var Server = grpc.buildServer([examples.RouteGuide.service]);
var COORD_FACTOR = 1e7;
/**
@ -222,27 +220,27 @@ function routeChat(call) {
* @return {Server} The new server object
*/
function getServer() {
return new Server({
'examples.RouteGuide' : {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
}
var server = new grpc.Server();
server.addProtoService(examples.RouteGuide.service, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
}
if (require.main === module) {
// If this is run as a script, start a server on an unused port
var routeServer = getServer();
routeServer.bind('0.0.0.0:50051');
routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
var argv = parseArgs(process.argv, {
string: 'db_path'
});
fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) throw err;
feature_list = JSON.parse(data);
routeServer.listen();
routeServer.start();
});
}

Loading…
Cancel
Save