Mercurial Hosting > luan
annotate src/goodjava/rpc/Rpc.java @ 1649:f7e2df85fc0a
add String.digest_message
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2022 16:07:01 -0600 |
parents | 0ba144491a42 |
children |
rev | line source |
---|---|
1402
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1118
diff
changeset
|
1 package goodjava.rpc; |
1118 | 2 |
3 import java.io.IOException; | |
4 | |
5 | |
6 // static utils | |
1491 | 7 public final class Rpc { |
1118 | 8 private Rpc() {} // never |
9 | |
1509 | 10 public static final RpcResult OK = new RpcResult(new Object[0]); |
1118 | 11 |
12 public static final RpcCall CLOSE = new RpcCall("close"); | |
13 public static final RpcCall PING = new RpcCall("ping"); | |
14 public static final String ECHO = "echo"; | |
15 | |
16 public static final RpcException COMMAND_NOT_FOUND = new RpcException("command_not_found"); | |
17 | |
18 public static boolean handle(RpcServer server,RpcCall call) | |
19 throws IOException | |
20 { | |
21 if( CLOSE.cmd.equals(call.cmd) ) { | |
22 server.close(); | |
23 return true; | |
24 } | |
25 if( PING.cmd.equals(call.cmd) ) { | |
26 server.write(OK); | |
27 return true; | |
28 } | |
29 if( ECHO.equals(call.cmd) ) { | |
30 server.write(new RpcResult(call.args)); | |
31 return true; | |
32 } | |
33 return false; | |
34 } | |
35 | |
36 } |