Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions examples/nodejs/client_stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const grpc = require("@grpc/grpc-js");
const protoLoader = require("@grpc/proto-loader");
const PROTO_PATH = "../../proto/inx.proto";


const INX_ADDRESS = "localhost:9029";


const protoOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};


// Load the `inx.proto` file
const packageDefinition = protoLoader.loadSync(PROTO_PATH, protoOptions);
const INX = grpc.loadPackageDefinition(packageDefinition).inx.INX;
// Instantiate an INX client
const client = new INX(
INX_ADDRESS,
grpc.credentials.createInsecure()
);

// Listen to the stream of latest milestones
var call = client.ListenToLatestMilestones();
call.on('data', function (answer) {
console.log(answer);
});
call.on('end', function () {
// The server has finished sending
});
call.on('error', function (error) {
// An error has occurred and the stream has been closed.
});
call.on('status', function (status) {
// process status
});
12 changes: 6 additions & 6 deletions examples/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.