From dbd83f729fe9f616ba5784fa5e1e3438654e3d93 Mon Sep 17 00:00:00 2001 From: Shintaro Kojima Date: Sun, 15 Nov 2015 21:51:51 +0900 Subject: Add an example of Node.js --- tools/grpc/nodejs/get_neighbors.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/grpc/nodejs/get_neighbors.js (limited to 'tools/grpc/nodejs') diff --git a/tools/grpc/nodejs/get_neighbors.js b/tools/grpc/nodejs/get_neighbors.js new file mode 100644 index 00000000..c1ec763b --- /dev/null +++ b/tools/grpc/nodejs/get_neighbors.js @@ -0,0 +1,24 @@ +var grpc = require('grpc'); +var api = grpc.load('gobgp.proto').gobgpapi; +var stub = new api.GobgpApi('localhost:8080', grpc.Credentials.createInsecure()); + +var call = stub.getNeighbors({}); +call.on('data', function(neighbor) { + console.log('BGP neighbor is', neighbor.conf.remote_ip, + ', remote AS', neighbor.conf.remote_as); + console.log("\tBGP version 4, remote route ID", neighbor.conf.id); + console.log("\tBGP state =", neighbor.info.bgp_state, + ', up for', neighbor.info.uptime); + console.log("\tBGP OutQ =", neighbor.info.out_q, + ', Flops =', neighbor.info.flops); + console.log("\tHold time is", neighbor.info.negotiated_holdtime, + ', keepalive interval is', neighbor.info.keepalive_interval, 'seconds'); + console.log("\tConfigured hold time is", neighbor.conf.holdtime); +}); +call.on('end', function() { + // do something when the server has finished sending +}); +call.on('status', function(status) { + // do something with the status +}); + -- cgit v1.2.3