Package com.chenshuo.muduo.protorpc.sudoku.SudokuProto

Examples of com.chenshuo.muduo.protorpc.sudoku.SudokuProto.SudokuRequest


    private static void blockingConnect(InetSocketAddress addr) throws Exception {
        RpcClient client = new RpcClient();
        RpcChannel channel = client.blockingConnect(addr);
        //sendRequest(channel, client);
        SudokuService.BlockingInterface remoteService = SudokuProto.SudokuService.newBlockingStub(channel);
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        SudokuResponse response = remoteService.solve(null, request);
        System.out.println(response);
        channel.disconnect();
        client.stop();
    }
View Full Code Here


    private static void sendAsyncRequest(final RpcChannel channel, RpcClient client) {
        final CountDownLatch latch = new CountDownLatch(1);
        System.err.println("sendRequest " + channel);
        SudokuService remoteService = SudokuProto.SudokuService.newStub(channel);
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        remoteService.solve(null, request, new RpcCallback<SudokuProto.SudokuResponse>() {
            @Override
            public void run(SudokuResponse parameter) {
                System.out.println(parameter);
                channel.disconnect();
View Full Code Here

    }

    @Test
    public void testDecoder() throws Exception {
        RpcEncoder encoder = new RpcEncoder();
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        RpcMessage message = RpcMessage.newBuilder().setType(MessageType.REQUEST).setId(1)
                .setService(SudokuService.getDescriptor().getName())
                .setMethod(SudokuService.getDescriptor().getMethods().get(0).getName())
                .setRequest(request.toByteString()).build();
        ChannelBuffer buffer = (ChannelBuffer) encoder.encode(null, null, message);

        RpcDecoder decoder = new RpcDecoder();
        RpcMessage decodedMessage = (RpcMessage) decoder.decode(null, null, buffer);
        assertEquals(1, decodedMessage.getId());
View Full Code Here

    @Test
    public void testClient() throws Exception {
        MockChannel mockChannel = new MockChannel();
        RpcChannel channel = new RpcChannel(mockChannel);
        SudokuService remoteService = SudokuProto.SudokuService.newStub(channel);
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        remoteService.solve(null, request, new RpcCallback<SudokuProto.SudokuResponse>() {
            @Override
            public void run(SudokuResponse response) {
                // System.out.println(parameter);
                gotResponse = response;
View Full Code Here

        services.put(SudokuService.getDescriptor().getName(),
                SudokuService.newReflectiveService(mockImpl));
        RpcChannel channel = new RpcChannel(mockChannel);
        channel.setServiceMap(services);

        SudokuRequest sudokuRequest = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        RpcMessage request = RpcMessage.newBuilder()
                .setType(MessageType.REQUEST)
                .setId(2)
                .setService(SudokuService.getDescriptor().getName())
                .setMethod("Solve")
                .setRequest(sudokuRequest.toByteString())
                .build();

        channel.messageReceived(null, new UpstreamMessageEvent(mockChannel, request, null));
        assertEquals(sudokuRequest, gotRequest);
View Full Code Here

TOP

Related Classes of com.chenshuo.muduo.protorpc.sudoku.SudokuProto.SudokuRequest

Copyright © 2018 www.massapicom. 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.