Home | History | Annotate | Download | only in static_codegen
      1 /*
      2  *
      3  * Copyright 2015 gRPC authors.
      4  *
      5  * 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
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * 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.
     16  *
     17  */
     18 
     19 var messages = require('./helloworld_pb');
     20 var services = require('./helloworld_grpc_pb');
     21 
     22 var grpc = require('grpc');
     23 
     24 /**
     25  * Implements the SayHello RPC method.
     26  */
     27 function sayHello(call, callback) {
     28   var reply = new messages.HelloReply();
     29   reply.setMessage('Hello ' + call.request.getName());
     30   callback(null, reply);
     31 }
     32 
     33 /**
     34  * Starts an RPC server that receives requests for the Greeter service at the
     35  * sample server port
     36  */
     37 function main() {
     38   var server = new grpc.Server();
     39   server.addService(services.GreeterService, {sayHello: sayHello});
     40   server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
     41   server.start();
     42 }
     43 
     44 main();
     45