Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const grpc = require('grpc');
- const path = require('path');
- const PROTO_PATH = path.join(__dirname, '/proto/p2p.proto');
- const DEFAULT_PORT = '40057';
- const p2p_proto = grpc.load(PROTO_PATH).p2p;
- function PingPong(call, callback) {
- console.log(call);
- callback(null, { pong: 'ABCDEFGH12345678' });
- }
- const server = new grpc.Server();
- server.addService(p2p_proto.Common.service, { PingPong: PingPong });
- server.bind('0.0.0.0:' + DEFAULT_PORT, grpc.ServerCredentials.createInsecure());
- server.start();
- const client = new p2p_proto.Common('localhost:' + DEFAULT_PORT,
- grpc.credentials.createInsecure());
- setInterval(() => client.PingPong({ ping: 'ZZZZAAAAQQQQ' }, function (err, response) {
- console.log('echo reply:', response.pong);
- }), 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement