@Test public void testClose() { markSourceConnected(true); assert !client.getListener().isClosed(); CompletableFuture<Boolean> wsFut = client.getWebsocketConnectionFuture(); CompletableFuture<Boolean> aFut = client.getAuthenticationFuture(); CompletableFuture<Boolean> sFut = client.getSourceConnectionFuture(); assert wsFut.getNow(false); assert aFut.getNow(false); assert sFut.getNow(false); ExtensionWebSocketListener oldListen = client.getListener(); client.close(); assert !client.getListener().isClosed(); assert oldListen.isClosed(); ExtensionWebSocketListener newListen = client.getListener(); assert newListen.authHandler == oldListen.authHandler; assert newListen.httpHandler == oldListen.httpHandler; assert newListen.configHandler == oldListen.configHandler; assert newListen.reconnectHandler == oldListen.reconnectHandler; assert newListen.publishHandler == oldListen.publishHandler; assert newListen.queryHandler == oldListen.queryHandler; assert !wsFut.getNow(true); assert !aFut.getNow(true); assert !sFut.getNow(true); assert client.getWebsocketConnectionFuture() == null; assert client.getAuthenticationFuture() == null; assert client.getSourceConnectionFuture() == null; }
public void close() { this.stop(); ExtensionWebSocketListener oldListener = listener; listener = new ExtensionWebSocketListener(this); listener.useHandlersFromListener(oldListener); if (this.closeHandler != null) { this.closeHandler.handleMessage(this); } }
ExtensionWebSocketClient { public void close() { this.stop(); ExtensionWebSocketListener oldListener = listener; listener = new ExtensionWebSocketListener(this); listener.useHandlersFromListener(oldListener); if (this.closeHandler != null) { this.closeHandler.handleMessage(this); } } }
ExtensionWebSocketClient { public void close() { this.stop(); ExtensionWebSocketListener oldListener = listener; listener = new ExtensionWebSocketListener(this); listener.useHandlersFromListener(oldListener); if (this.closeHandler != null) { this.closeHandler.handleMessage(this); } } ExtensionWebSocketClient(String sourceName); }
ExtensionWebSocketClient { public void close() { this.stop(); ExtensionWebSocketListener oldListener = listener; listener = new ExtensionWebSocketListener(this); listener.useHandlersFromListener(oldListener); if (this.closeHandler != null) { this.closeHandler.handleMessage(this); } } ExtensionWebSocketClient(String sourceName); ExtensionWebSocketListener getListener(); String getSourceName(); CompletableFuture<Boolean> initiateFullConnection(String url, String token); synchronized CompletableFuture<Boolean> initiateWebsocketConnection(String url); CompletableFuture<Boolean> getWebsocketConnectionFuture(); void sendNotification(Object data); void sendQueryResponseEmpty(String replyAddress); void sendQueryResponse(int httpCode, String replyAddress, Map body); void sendQueryResponse(int httpCode, String replyAddress, Map[] body); void sendQueryError(String replyAddress, String messageCode, String messageTemplate, Object[] parameters); void send(Object obj); synchronized CompletableFuture<Boolean> authenticate(String user, String pass); synchronized CompletableFuture<Boolean> authenticate(String token); CompletableFuture<Boolean> getAuthenticationFuture(); synchronized CompletableFuture<Boolean> connectToSource(); CompletableFuture<Boolean> getSourceConnectionFuture(); void sourceHasDisconnected(); void setAutoReconnect(boolean value); boolean isOpen(); boolean isAuthed(); boolean isConnected(); void close(); void stop(); void useHandlersFrom(ExtensionWebSocketListener listener); void useHandlersFrom(ExtensionWebSocketClient client); void setCloseHandler(Handler<ExtensionWebSocketClient> closeHandler); void setHttpHandler(Handler<Response> httpHandler); void setPublishHandler(Handler<ExtensionServiceMessage> publishHandler); void setQueryHandler(Handler<ExtensionServiceMessage> queryHandler); void setConfigHandler(Handler<ExtensionServiceMessage> configHandler); void setAuthHandler(Handler<Response> authHandler); void setReconnectHandler(Handler<ExtensionServiceMessage> reconnectHandler); }
ExtensionWebSocketClient { public void close() { this.stop(); ExtensionWebSocketListener oldListener = listener; listener = new ExtensionWebSocketListener(this); listener.useHandlersFromListener(oldListener); if (this.closeHandler != null) { this.closeHandler.handleMessage(this); } } ExtensionWebSocketClient(String sourceName); ExtensionWebSocketListener getListener(); String getSourceName(); CompletableFuture<Boolean> initiateFullConnection(String url, String token); synchronized CompletableFuture<Boolean> initiateWebsocketConnection(String url); CompletableFuture<Boolean> getWebsocketConnectionFuture(); void sendNotification(Object data); void sendQueryResponseEmpty(String replyAddress); void sendQueryResponse(int httpCode, String replyAddress, Map body); void sendQueryResponse(int httpCode, String replyAddress, Map[] body); void sendQueryError(String replyAddress, String messageCode, String messageTemplate, Object[] parameters); void send(Object obj); synchronized CompletableFuture<Boolean> authenticate(String user, String pass); synchronized CompletableFuture<Boolean> authenticate(String token); CompletableFuture<Boolean> getAuthenticationFuture(); synchronized CompletableFuture<Boolean> connectToSource(); CompletableFuture<Boolean> getSourceConnectionFuture(); void sourceHasDisconnected(); void setAutoReconnect(boolean value); boolean isOpen(); boolean isAuthed(); boolean isConnected(); void close(); void stop(); void useHandlersFrom(ExtensionWebSocketListener listener); void useHandlersFrom(ExtensionWebSocketClient client); void setCloseHandler(Handler<ExtensionWebSocketClient> closeHandler); void setHttpHandler(Handler<Response> httpHandler); void setPublishHandler(Handler<ExtensionServiceMessage> publishHandler); void setQueryHandler(Handler<ExtensionServiceMessage> queryHandler); void setConfigHandler(Handler<ExtensionServiceMessage> configHandler); void setAuthHandler(Handler<Response> authHandler); void setReconnectHandler(Handler<ExtensionServiceMessage> reconnectHandler); static final int QUERY_CHUNK_CODE; static final int QUERY_DATA_CODE; static final int QUERY_NODATA_CODE; }