Preventing a NPE
- We're now checking that there is a selected node before trying to use it, and in case there is none we schedule a retry in DEFAULT_INITIAL_DELAY ms.
This commit is contained in:
parent
b5e2961834
commit
b032db80bc
1 changed files with 7 additions and 3 deletions
|
@ -229,9 +229,13 @@ public class NetworkService extends Service {
|
|||
.writeTimeout(5, TimeUnit.SECONDS)
|
||||
.build();
|
||||
mSelectedNode = nodeProvider.getBestNode();
|
||||
Log.v(TAG,"connect.url: "+ mSelectedNode.getUrl()+", latency: "+mSelectedNode.getLatencyValue());
|
||||
Request request = new Request.Builder().url(mSelectedNode.getUrl()).build();
|
||||
mWebSocket = client.newWebSocket(request, mWebSocketListener);
|
||||
if(mSelectedNode != null){
|
||||
Request request = new Request.Builder().url(mSelectedNode.getUrl()).build();
|
||||
mWebSocket = client.newWebSocket(request, mWebSocketListener);
|
||||
}else{
|
||||
// If no node could be found yet, schedule a new attempt in DEFAULT_INITIAL_DELAY ms
|
||||
mHandler.postDelayed(mConnectAttempt, DEFAULT_INITIAL_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
public long sendMessage(String message){
|
||||
|
|
Loading…
Reference in a new issue