comparison src/luan/lib/rpc/RpcClient.java @ 1119:87c674f3f6b7

add RpcError
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Aug 2017 12:35:45 -0600
parents e4710ddfd287
children
comparison
equal deleted inserted replaced
1118:e4710ddfd287 1119:87c674f3f6b7
1 package luan.lib.rpc; 1 package luan.lib.rpc;
2 2
3 import java.io.IOException;
4 import java.net.Socket; 3 import java.net.Socket;
5 import java.util.List; 4 import java.util.List;
6 import java.util.ArrayList; 5 import java.util.ArrayList;
7 6
8 7
9 public class RpcClient extends RpcCon { 8 public class RpcClient extends RpcCon {
10 9
11 public RpcClient(Socket socket) throws IOException { 10 public RpcClient(Socket socket)
11 throws RpcError
12 {
12 super(socket); 13 super(socket);
13 } 14 }
14 15
15 public void write(RpcCall call) 16 public void write(RpcCall call)
16 throws IOException 17 throws RpcError
17 { 18 {
18 List list = new ArrayList(); 19 List list = new ArrayList();
19 list.add(call.cmd); 20 list.add(call.cmd);
20 for( Object arg : call.args ) { 21 for( Object arg : call.args ) {
21 list.add(arg); 22 list.add(arg);
22 } 23 }
23 write(call.in,call.lenIn,list); 24 write(call.in,call.lenIn,list);
24 } 25 }
25 26
26 public RpcResult read() 27 public RpcResult read()
27 throws IOException, RpcException 28 throws RpcError, RpcException
28 { 29 {
29 List list = readJson(); 30 List list = readJson();
30 boolean ok = (Boolean)list.remove(0); 31 boolean ok = (Boolean)list.remove(0);
31 if( !ok ) { 32 if( !ok ) {
32 String errorId = (String)list.remove(0); 33 String errorId = (String)list.remove(0);