Mercurial Hosting > luan
annotate src/goodjava/rpc/Rpc.java @ 2023:544ccce564f6 default tip
minor
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 20 Oct 2025 17:34:14 -0600 |
| parents | a8bab2b60b67 |
| 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 boolean handle(RpcServer server,RpcCall call) | |
| 17 throws IOException | |
| 18 { | |
| 19 if( CLOSE.cmd.equals(call.cmd) ) { | |
| 20 server.close(); | |
| 21 return true; | |
| 22 } | |
| 23 if( PING.cmd.equals(call.cmd) ) { | |
| 24 server.write(OK); | |
| 25 return true; | |
| 26 } | |
| 27 if( ECHO.equals(call.cmd) ) { | |
| 28 server.write(new RpcResult(call.args)); | |
| 29 return true; | |
| 30 } | |
| 31 return false; | |
| 32 } | |
| 33 | |
| 34 } |
