Package com.chenshuo.muduo.protorpc.echo

Source Code of com.chenshuo.muduo.protorpc.echo.EchoServer

package com.chenshuo.muduo.protorpc.echo;

import com.chenshuo.muduo.protorpc.RpcServer;
import com.chenshuo.muduo.protorpc.echo.EchoProto;
import com.chenshuo.muduo.protorpc.echo.EchoProto.EchoRequest;
import com.chenshuo.muduo.protorpc.echo.EchoProto.EchoResponse;
import com.chenshuo.muduo.protorpc.echo.EchoProto.EchoService.Interface;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;

public class EchoServer {

    public static void main(String[] args) {
        RpcServer server = new RpcServer();
        server.registerService(EchoProto.EchoService.newReflectiveService(new Interface() {
            @Override
            public void echo(RpcController controller, EchoRequest request, RpcCallback<EchoResponse> done) {
                done.run(EchoResponse.newBuilder().setPayload(request.getPayload()).build());
            }
        }));
        server.start(8888);
    }
}
TOP

Related Classes of com.chenshuo.muduo.protorpc.echo.EchoServer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.