blob: 180f96c28b88e498549f8a3ecc64d0782a3ebc7e [file] [log] [blame]
murgatroid99e89af552015-02-19 13:33:04 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
murgatroid99e89af552015-02-19 13:33:04 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
murgatroid99e89af552015-02-19 13:33:04 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
murgatroid99e89af552015-02-19 13:33:04 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
murgatroid99e89af552015-02-19 13:33:04 -080016 *
17 */
18
murgatroid99ddc0eb12016-05-04 10:27:12 -070019var PROTO_PATH = __dirname + '/../../protos/helloworld.proto';
murgatroid994c8f8d82016-02-26 11:43:05 -080020
murgatroid99c7edb0e2016-04-29 15:33:31 -070021var grpc = require('grpc');
22var hello_proto = grpc.load(PROTO_PATH).helloworld;
murgatroid99e89af552015-02-19 13:33:04 -080023
murgatroid99e89af552015-02-19 13:33:04 -080024/**
Yang Gao600d70c2015-02-20 10:50:46 -080025 * Implements the SayHello RPC method.
murgatroid99e89af552015-02-19 13:33:04 -080026 */
Yang Gao34405482015-02-20 11:35:20 -080027function sayHello(call, callback) {
murgatroid99c7edb0e2016-04-29 15:33:31 -070028 callback(null, {message: 'Hello ' + call.request.name});
murgatroid99e89af552015-02-19 13:33:04 -080029}
30
31/**
32 * Starts an RPC server that receives requests for the Greeter service at the
33 * sample server port
34 */
35function main() {
murgatroid99c9192282015-08-28 15:24:07 -070036 var server = new grpc.Server();
Florian Nagela36b4292017-10-03 15:21:14 +020037 server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
murgatroid99c9192282015-08-28 15:24:07 -070038 server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
39 server.start();
murgatroid99e89af552015-02-19 13:33:04 -080040}
41
42main();