Mercurial Hosting > luan
annotate src/goodjava/rpc/RpcClient.java @ 1721:5c69d2e8bd75
no regex in String.find and String.split
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 26 Jul 2022 12:44:52 -0600 |
parents | 27efb1fcbcb5 |
children |
rev | line source |
---|---|
1402
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1119
diff
changeset
|
1 package goodjava.rpc; |
1118 | 2 |
3 import java.net.Socket; | |
4 import java.util.List; | |
5 import java.util.ArrayList; | |
6 | |
7 | |
8 public class RpcClient extends RpcCon { | |
9 | |
1119 | 10 public RpcClient(Socket socket) |
11 throws RpcError | |
12 { | |
1118 | 13 super(socket); |
14 } | |
15 | |
16 public void write(RpcCall call) | |
1119 | 17 throws RpcError |
1118 | 18 { |
19 List list = new ArrayList(); | |
20 list.add(call.cmd); | |
21 for( Object arg : call.args ) { | |
22 list.add(arg); | |
23 } | |
24 write(call.in,call.lenIn,list); | |
25 } | |
26 | |
27 public RpcResult read() | |
1119 | 28 throws RpcError, RpcException |
1118 | 29 { |
30 List list = readJson(); | |
31 boolean ok = (Boolean)list.remove(0); | |
32 if( !ok ) { | |
33 String errorId = (String)list.remove(0); | |
34 Object[] args = list.toArray(); | |
35 throw new RpcException(inBinary,lenBinary,errorId,args); | |
36 } | |
37 Object[] args = list.toArray(); | |
38 return new RpcResult(inBinary,lenBinary,args); | |
39 } | |
40 | |
41 } |