|
1 | 1 | package com.nerox.client.modules; |
2 | 2 |
|
3 | | -import com.nerox.client.Tfprotocol; |
| 3 | +import java.io.InputStream; |
| 4 | +import java.lang.reflect.Method; |
| 5 | + |
4 | 6 | import com.nerox.client.TfprotocolSuper; |
5 | 7 | import com.nerox.client.callbacks.IXSRPCProxyCallback; |
| 8 | +import com.nerox.client.misc.StatusInfo; |
| 9 | + |
6 | 10 |
|
7 | 11 | public class XSRPCProxy extends TfprotocolSuper<IXSRPCProxyCallback>{ |
8 | | - public boolean startCommand(){ |
9 | | - super.getProtoHandler().startRPCProxyCallback( |
| 12 | + |
| 13 | + public XSRPCProxy(String ipServer, int portServer, String publicKey, |
| 14 | + String hash, int len, String protocol, IXSRPCProxyCallback protoHandler) { |
| 15 | + super(ipServer, portServer, publicKey, hash, len, protocol, protoHandler); |
| 16 | + } |
| 17 | + |
| 18 | + public XSRPCProxy(String proxy, String ipServer, int portServer, String publicKey, |
| 19 | + String hash, int len, String protocol, IXSRPCProxyCallback protoHandler) { |
| 20 | + super(proxy, ipServer, portServer, publicKey, hash, len, protocol, protoHandler); |
| 21 | + } |
| 22 | + |
| 23 | + public XSRPCProxy(TfprotocolSuper tfprotocol, IXSRPCProxyCallback protoHandler) { |
| 24 | + this.setProtoHandler(protoHandler); |
| 25 | + this.easyreum = tfprotocol.getConHandler(); |
| 26 | + } |
| 27 | + |
| 28 | + public XSRPCProxy(String ipServer, int portServer, InputStream publicKey, |
| 29 | + String hash, int len, String protocol, |
| 30 | + IXSRPCProxyCallback protoHandler){ |
| 31 | + super(ipServer, portServer, publicKey, hash, len, protocol, protoHandler); |
| 32 | + } |
| 33 | + |
| 34 | + public void startCommand(){ |
| 35 | + this.getProtoHandler().startRPCProxyCallback( |
10 | 36 | this.easyreum.getBuilder().build("XS_RPCPROXY").translate() |
11 | 37 | .getBuilder().buildStatusInfo() |
12 | 38 | ); |
13 | 39 | } |
14 | | - |
| 40 | + public boolean sendHashCommand(String hash){ |
| 41 | + this.easyreum.getBuilder().build(hash).send(); |
| 42 | + this.easyreum.receiveHeader(); |
| 43 | + return this.easyreum.getHeader() == 0; |
| 44 | + } |
| 45 | + public int sendPayload(String payload){ |
| 46 | + return this.sendPayload(payload.getBytes()); |
| 47 | + } |
| 48 | + public int sendPayload(byte[] payload){ |
| 49 | + this.easyreum.getBuilder().build(payload).send(); |
| 50 | + this.easyreum.getBuilder().build(0).sendJust(); |
| 51 | + do{ |
| 52 | + this.getProtoHandler().receivePayload(this.easyreum.receive().getBuilder().buildStatusInfo()); |
| 53 | + }while(this.easyreum.getHeader() > 0); |
| 54 | + this.easyreum.receiveHeader(); |
| 55 | + return this.easyreum.getHeader(); |
| 56 | + } |
| 57 | + |
| 58 | + public void exitCommand(){ |
| 59 | + this.easyreum.getBuilder().build(-1).sendJust(); |
| 60 | + } |
15 | 61 | } |
0 commit comments