run JSON-RPC server in separate Thread.
This commit is contained in:
parent
386c94f4bb
commit
1127f0dd88
|
@ -301,9 +301,14 @@ public class EthereumRemoteService extends EthereumService {
|
|||
*/
|
||||
protected void startJsonRpc(Message message) {
|
||||
|
||||
// TODO: Maybe send back if it started succesfully ?
|
||||
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!");
|
||||
|
@ -311,6 +316,10 @@ public class EthereumRemoteService extends EthereumService {
|
|||
logger.error("Exception starting json rpc server: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
jsonRpcServerThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an online peer
|
||||
|
|
|
@ -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