@Test public void willFallbackToMessengerIfNotConnected() throws RemoteException { setupMockBoundMessengerService(); createObservableSendDataAndSubscribe("connect with me"); sendConnectionParamsFromServer(); setWebSocketConnectedState(false); observableWebSocketClient.sendMessage("Stop messaging me").test(); verify(observableWebSocketClient.okWebSocketClient, times(0)).sendMessage(anyString()); verifyMessagesSentToServerViaMessenger(2); }
@Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } }
ObservableWebSocketClient extends ObservableMessengerClient { @Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } } }
ObservableWebSocketClient extends ObservableMessengerClient { @Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } } ObservableWebSocketClient(Context context, ComponentName serviceComponentName); }
ObservableWebSocketClient extends ObservableMessengerClient { @Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } } ObservableWebSocketClient(Context context, ComponentName serviceComponentName); @Override Completable connect(); @Override boolean isConnected(); @Override Observable<String> sendMessage(final String message); @Override void closeConnection(); }
ObservableWebSocketClient extends ObservableMessengerClient { @Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } } ObservableWebSocketClient(Context context, ComponentName serviceComponentName); @Override Completable connect(); @Override boolean isConnected(); @Override Observable<String> sendMessage(final String message); @Override void closeConnection();  }