/** * Attempt to establish a connection to rosbridge. Errors are printed to the * error output stream. * * @return Returns true if the connection was established successfully and * false otherwise. */ public boolean connect() { try { // create a WebSocket connection here URI uri = new URI(this.getURL()); ContainerProvider.getWebSocketContainer() .connectToServer(this, uri); return true; } catch (DeploymentException | URISyntaxException | IOException e) { // failed connection, return false System.err.println("[ERROR]: Could not create WebSocket: " + e.getMessage()); return false; } }
/** * Attempt to establish a connection to rosbridge. Errors are printed to the * error output stream. * * @return Returns true if the connection was established successfully and * false otherwise. */ public boolean connect() { try { // create a WebSocket connection here URI uri = new URI(this.getURL()); ContainerProvider.getWebSocketContainer() .connectToServer(this, uri); return true; } catch (DeploymentException | URISyntaxException | IOException e) { // failed connection, return false System.err.println("[ERROR]: Could not create WebSocket: " + e.getMessage()); return false; } }