@Test public void testValidifyUrl() { String url = "ws: url = client.validifyUrl(url); assert url.equals("ws: url = "http: url = client.validifyUrl(url); assert url.equals("ws: url = "http: url = client.validifyUrl(url); assert url.equals("ws: url = "http: url = client.validifyUrl(url); assert url.equals("ws: url = "http: url = client.validifyUrl(url); assert url.equals("ws: url = "https: url = client.validifyUrl(url); assert url.equals("wss: url = "https: url = client.validifyUrl(url); assert url.equals("wss: url = "dev.vantiq.com"; url = client.validifyUrl(url); assert url.equals("wss: url = "https: url = client.validifyUrl(url); assert url.equals("wss: url = "https: url = client.validifyUrl(url); assert url.equals("wss: url = "https: url = client.validifyUrl(url); assert url.equals("wss: url = "https: url = client.validifyUrl(url); assert url.equals("wss: }
protected String validifyUrl(String url) { if (url == null) { throw new IllegalArgumentException("Must give a valid URL to connect to the websocket"); } boolean usesSSL = true; if (url.startsWith("http: url = url.substring("http: usesSSL = false; } else if (url.startsWith("https: url = url.substring("https: } if (!url.startsWith("ws: String prefix = "wss: if (!usesSSL) { prefix = "ws: } url = prefix + url; } if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) { if (!url.endsWith("/")) { url = url + "/"; } url = url + "api/v1/wsock/websocket"; } return url; }
ExtensionWebSocketClient { protected String validifyUrl(String url) { if (url == null) { throw new IllegalArgumentException("Must give a valid URL to connect to the websocket"); } boolean usesSSL = true; if (url.startsWith("http: url = url.substring("http: usesSSL = false; } else if (url.startsWith("https: url = url.substring("https: } if (!url.startsWith("ws: String prefix = "wss: if (!usesSSL) { prefix = "ws: } url = prefix + url; } if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) { if (!url.endsWith("/")) { url = url + "/"; } url = url + "api/v1/wsock/websocket"; } return url; } }
ExtensionWebSocketClient { protected String validifyUrl(String url) { if (url == null) { throw new IllegalArgumentException("Must give a valid URL to connect to the websocket"); } boolean usesSSL = true; if (url.startsWith("http: url = url.substring("http: usesSSL = false; } else if (url.startsWith("https: url = url.substring("https: } if (!url.startsWith("ws: String prefix = "wss: if (!usesSSL) { prefix = "ws: } url = prefix + url; } if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) { if (!url.endsWith("/")) { url = url + "/"; } url = url + "api/v1/wsock/websocket"; } return url; } ExtensionWebSocketClient(String sourceName); }
ExtensionWebSocketClient { protected String validifyUrl(String url) { if (url == null) { throw new IllegalArgumentException("Must give a valid URL to connect to the websocket"); } boolean usesSSL = true; if (url.startsWith("http: url = url.substring("http: usesSSL = false; } else if (url.startsWith("https: url = url.substring("https: } if (!url.startsWith("ws: String prefix = "wss: if (!usesSSL) { prefix = "ws: } url = prefix + url; } if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) { if (!url.endsWith("/")) { url = url + "/"; } url = url + "api/v1/wsock/websocket"; } return url; } 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 { protected String validifyUrl(String url) { if (url == null) { throw new IllegalArgumentException("Must give a valid URL to connect to the websocket"); } boolean usesSSL = true; if (url.startsWith("http: url = url.substring("http: usesSSL = false; } else if (url.startsWith("https: url = url.substring("https: } if (!url.startsWith("ws: String prefix = "wss: if (!usesSSL) { prefix = "ws: } url = prefix + url; } if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) { if (!url.endsWith("/")) { url = url + "/"; } url = url + "api/v1/wsock/websocket"; } return url; } 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; }