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