@Override public void connectToExternal() throws ComponentException { String patternString = "(?<protocol>wss?):\\/\\/(?<host>.*):(?<port>\\d*)"; Pattern pattern = Pattern.compile(patternString); Matcher matcher = pattern.matcher(componentConfig.getExternalConnectionString()); boolean matches = matcher.matches(); if (!matches) { throw new ComponentException("Invalid external connection string! " + componentConfig.getExternalConnectionString() + " does not match the expected pattern " + patternString); } protocol = matcher.group("protocol"); host = matcher.group("host"); port = Integer.parseInt(matcher.group("port")); //TODO: support also wss ros = new Ros(host, port, WebSocketType.valueOf(protocol)); if (!ros.connect()) { throw new ComponentException( getName() + " cannot connect to \"" + componentConfig.getExternalConnectionString() + "\""); } }
/** * Get the full URL this client is connecting to. * * @return the url */ public String getURL() { return this.protocol.toString() + "://" + this.hostname + ":" + this.port; }
/** * Get the full URL this client is connecting to. * * @return */ public String getURL() { return this.protocol.toString() + "://" + this.hostname + ":" + this.port; }