private void completeRequest(short id, byte originalType, Object arg) { Request request = requests.remove(id); if( request!=null ) { assert originalType==request.frame.messageType(); if(request.cb!=null) { if( arg==null ) { ((Callback<Void>)request.cb).onSuccess(null); } else { ((Callback<Object>)request.cb).onSuccess(arg); } } } else { handleFatalFailure(new ProtocolException("Command from server contained an invalid message id: " + id)); } }
void handleSessionFailure(Throwable error) { // Socket failure, should we try to reconnect? if( !disconnected && (mqtt.reconnectAttemptsMax<0 || reconnects < mqtt.reconnectAttemptsMax ) ) { mqtt.tracer.debug("Reconnecting transport"); // Cleanup the previous transport. if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } final Transport t = transport; transport = null; if(t!=null) { t.stop(new Task() { @Override public void run() { listener.onDisconnected(); reconnect(); } }); } else { reconnect(); } } else { // nope. handleFatalFailure(error); } }
private void completeRequest(short id, byte originalType, Object arg) { Request request = requests.remove(id); if( request!=null ) { assert originalType==request.frame.messageType(); if(request.cb!=null) { if( arg==null ) { ((Callback<Void>)request.cb).onSuccess(null); } else { ((Callback<Object>)request.cb).onSuccess(arg); } } } else { handleFatalFailure(new ProtocolException("Command from server contained an invalid message id: " + id)); } }
void handleSessionFailure(Throwable error) { // Socket failure, should we try to reconnect? if( !disconnected && (mqtt.reconnectAttemptsMax<0 || reconnects < mqtt.reconnectAttemptsMax ) ) { mqtt.tracer.debug("Reconnecting transport"); // Cleanup the previous transport. if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } final Transport t = transport; transport = null; if(t!=null) { t.stop(new Task() { @Override public void run() { listener.onDisconnected(); reconnect(); } }); } else { reconnect(); } } else { // nope. handleFatalFailure(error); } }