1b5a588dfSShuo Chenpackage echo; 2b5a588dfSShuo Chen 3b5a588dfSShuo Chenimport com.google.protobuf.RpcCallback; 4b5a588dfSShuo Chenimport com.google.protobuf.RpcController; 5b5a588dfSShuo Chen 6b5a588dfSShuo Chenimport echo.EchoProto.EchoRequest; 7b5a588dfSShuo Chenimport echo.EchoProto.EchoResponse; 8b5a588dfSShuo Chenimport echo.EchoProto.EchoService.Interface; 9b5a588dfSShuo Chenimport muduo.rpc.RpcServer; 10b5a588dfSShuo Chen 11b5a588dfSShuo Chenpublic class EchoServer { 12b5a588dfSShuo Chen 13b5a588dfSShuo Chen public static void main(String[] args) { 14b5a588dfSShuo Chen RpcServer server = new RpcServer(); 15b5a588dfSShuo Chen server.registerService(EchoProto.EchoService.newReflectiveService(new Interface() { 16b5a588dfSShuo Chen @Override 17b5a588dfSShuo Chen public void echo(RpcController controller, EchoRequest request, RpcCallback<EchoResponse> done) { 18b5a588dfSShuo Chen done.run(EchoResponse.newBuilder().setPayload(request.getPayload()).build()); 19b5a588dfSShuo Chen } 20b5a588dfSShuo Chen })); 21b5a588dfSShuo Chen server.start(8888); 22b5a588dfSShuo Chen } 23b5a588dfSShuo Chen} 24