From 767482b093cfa9faa539aa6574fce9b9ba2ac3a1 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 9 Feb 2015 11:50:19 -0800 Subject: Fixed math and stock servers --- src/node/examples/stock_server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/node/examples/stock_server.js') diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js index c188181b77..07cea2ce5f 100644 --- a/src/node/examples/stock_server.js +++ b/src/node/examples/stock_server.js @@ -35,7 +35,7 @@ var _ = require('underscore'); var grpc = require('..'); var examples = grpc.load(__dirname + '/stock.proto').examples; -var StockServer = grpc.makeServerConstructor([examples.Stock.service]); +var StockServer = grpc.buildServer([examples.Stock.service]); function getLastTradePrice(call, callback) { callback(null, {price: 88}); @@ -80,4 +80,9 @@ var stockServer = new StockServer({ } }); +if (require.main === module) { + stockServer.bind('0.0.0.0:8080'); + stockServer.listen(); +} + exports.module = stockServer; -- cgit v1.2.3 From d95a16c4f49c2ccaec55a2fbcc87d72d0b1bb638 Mon Sep 17 00:00:00 2001 From: Jun Yang Date: Mon, 9 Feb 2015 13:43:56 -0800 Subject: Added echoing of requested stock symbol. This makes the example more realistic. --- src/node/examples/stock_server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/node/examples/stock_server.js') diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js index 07cea2ce5f..61ba273155 100644 --- a/src/node/examples/stock_server.js +++ b/src/node/examples/stock_server.js @@ -38,7 +38,7 @@ var examples = grpc.load(__dirname + '/stock.proto').examples; var StockServer = grpc.buildServer([examples.Stock.service]); function getLastTradePrice(call, callback) { - callback(null, {price: 88}); + callback(null, {symbol: call.request.symbol, price: 88}); } function watchFutureTrades(call) { -- cgit v1.2.3 From 79a78c2289a89b525fcdfa5c145a22e41e46b0f3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 9 Feb 2015 15:58:33 -0800 Subject: Fixed typo in stock_server.js0 --- src/node/examples/stock_server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/node/examples/stock_server.js') diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js index 61ba273155..b226a71573 100644 --- a/src/node/examples/stock_server.js +++ b/src/node/examples/stock_server.js @@ -85,4 +85,4 @@ if (require.main === module) { stockServer.listen(); } -exports.module = stockServer; +module.exports = stockServer; -- cgit v1.2.3