run JSON-RPC server in separate Thread.
This commit is contained in:
parent
386c94f4bb
commit
1127f0dd88
|
@ -301,14 +301,23 @@ public class EthereumRemoteService extends EthereumService {
|
|||
*/
|
||||
protected void startJsonRpc(Message message) {
|
||||
|
||||
// TODO: Maybe send back if it started succesfully ?
|
||||
//TODO: add here switch between full and light version
|
||||
jsonRpcServer = new org.ethereum.android.jsonrpc.light.JsonRpcServer(ethereum);
|
||||
try {
|
||||
jsonRpcServer.start();
|
||||
logger.info("Started json rpc server!");
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception starting json rpc server: " + e.getMessage());
|
||||
if (jsonRpcServer == null) {
|
||||
//TODO: add here switch between full and light version
|
||||
jsonRpcServer = new org.ethereum.android.jsonrpc.light.JsonRpcServer(ethereum);
|
||||
}
|
||||
if (jsonRpcServerThread == null) {
|
||||
jsonRpcServerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
jsonRpcServer.start();
|
||||
logger.info("Started json rpc server!");
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception starting json rpc server: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
jsonRpcServerThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public class EthereumService extends Service {
|
|||
static Ethereum ethereum = null;
|
||||
|
||||
static JsonRpcServer jsonRpcServer;
|
||||
static Thread jsonRpcServerThread;
|
||||
|
||||
public EthereumService() {
|
||||
}
|
||||
|
@ -49,6 +50,13 @@ public class EthereumService extends Service {
|
|||
initializeEthereum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (jsonRpcServerThread != null) {
|
||||
jsonRpcServerThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
protected void initializeEthereum() {
|
||||
|
||||
if (!isInitialized) {
|
||||
|
|
Loading…
Reference in New Issue