Psi.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Java Package psi is a proxy for talking to a Go program.
  2. // gobind -lang=java github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary/psi
  3. //
  4. // File is generated by gobind. Do not edit.
  5. package go.psi;
  6. import go.Seq;
  7. public abstract class Psi {
  8. private Psi() {} // uninstantiable
  9. public interface Listener extends go.Seq.Object {
  10. public void Message(String message);
  11. public static abstract class Stub implements Listener {
  12. static final String DESCRIPTOR = "go.psi.Listener";
  13. private final go.Seq.Ref ref;
  14. public Stub() {
  15. ref = go.Seq.createRef(this);
  16. }
  17. public go.Seq.Ref ref() { return ref; }
  18. public void call(int code, go.Seq in, go.Seq out) {
  19. switch (code) {
  20. case Proxy.CALL_Message: {
  21. String param_message = in.readUTF16();
  22. this.Message(param_message);
  23. return;
  24. }
  25. default:
  26. throw new RuntimeException("unknown code: "+ code);
  27. }
  28. }
  29. }
  30. static final class Proxy implements Listener {
  31. static final String DESCRIPTOR = Stub.DESCRIPTOR;
  32. private go.Seq.Ref ref;
  33. Proxy(go.Seq.Ref ref) { this.ref = ref; }
  34. public go.Seq.Ref ref() { return ref; }
  35. public void call(int code, go.Seq in, go.Seq out) {
  36. throw new RuntimeException("cycle: cannot call proxy");
  37. }
  38. public void Message(String message) {
  39. go.Seq _in = new go.Seq();
  40. go.Seq _out = new go.Seq();
  41. _in.writeRef(ref);
  42. _in.writeUTF16(message);
  43. Seq.send(DESCRIPTOR, CALL_Message, _in, _out);
  44. }
  45. static final int CALL_Message = 0x10a;
  46. }
  47. }
  48. public static void Start(String configJson, Listener listener) throws Exception {
  49. go.Seq _in = new go.Seq();
  50. go.Seq _out = new go.Seq();
  51. _in.writeUTF16(configJson);
  52. _in.writeRef(listener.ref());
  53. Seq.send(DESCRIPTOR, CALL_Start, _in, _out);
  54. String _err = _out.readUTF16();
  55. if (_err != null) {
  56. throw new Exception(_err);
  57. }
  58. }
  59. public static void Stop() {
  60. go.Seq _in = new go.Seq();
  61. go.Seq _out = new go.Seq();
  62. Seq.send(DESCRIPTOR, CALL_Stop, _in, _out);
  63. }
  64. private static final int CALL_Start = 1;
  65. private static final int CALL_Stop = 2;
  66. private static final String DESCRIPTOR = "psi";
  67. }