Fixed math and stock servers

pull/436/head
murgatroid99 10 years ago
parent d2785749f8
commit 767482b093
  1. 3
      src/node/examples/math_server.js
  2. 14
      src/node/examples/stock.proto
  3. 7
      src/node/examples/stock_server.js

@ -128,7 +128,8 @@ var server = new Server({
});
if (require.main === module) {
server.bind('localhost:7070').listen();
server.bind('0.0.0.0:7070');
server.listen();
}
/**

@ -35,28 +35,28 @@ package examples;
message StockRequest {
optional string symbol = 1;
optional int32 num_trades_to_watch = 2 [default=0];
};
}
message StockReply {
optional float price = 1;
optional string symbol = 2;
};
}
// Interface exported by the server
service Stock {
// Simple blocking RPC
rpc GetLastTradePrice(StockRequest) returns (StockReply) {
};
}
// Bidirectional streaming RPC
rpc GetLastTradePriceMultiple(stream StockRequest) returns
(stream StockReply) {
};
}
// Unidirectional server-to-client streaming RPC
rpc WatchFutureTrades(StockRequest) returns (stream StockReply) {
};
}
// Unidirectional client-to-server streaming RPC
rpc GetHighestTradePrice(stream StockRequest) returns (StockReply) {
};
}
};
}

@ -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;

Loading…
Cancel
Save