Mercurial Hosting > luan
annotate src/goodjava/rpc/RpcClient.java @ 2021:b8e5d53c4fc9
admin monitors scheduler
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 20 Oct 2025 14:45:27 -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 } |
