/** * Sets url and callback and initiates connecting if both are present * * @param url the url * @param callback the callback * @return true if connecting has been initiated, false if not */ private boolean setAndConnect(URL url, IOCallback callback) { if (this.connection != null) throw new RuntimeException( "You can connect your SocketIO instance only once. Use a fresh instance instead."); if ((this.url != null && url != null) || (this.callback != null && callback != null)) return false; if (url != null) { this.url = url; } if (callback != null) { this.callback = callback; } if (this.callback != null && this.url != null) { final String origin = this.url.getProtocol() + "://" + this.url.getAuthority(); this.namespace = this.url.getPath(); if (this.namespace.equals("/")) { this.namespace = ""; } this.connection = IOConnection.register(origin, this); return true; } return false; }