List of usage examples for android.net Uri getEncodedAuthority
@Nullable public abstract String getEncodedAuthority();
From source file:com.appunite.socketio.SocketIOBase.java
private ConnectionResult connect(String url) throws WrongHttpResponseCode, IOException, WrongSocketIOResponse, InterruptedException { Uri uri = Uri.parse(url); synchronized (mInterruptionLock) { if (mInterrupted) { throw new InterruptedException(); }// w w w .j a v a2 s .c o m mRequest = new HttpGet(url); } HTTPUtils.setupDefaultHeaders(mRequest); HttpResponse response = getClient().execute(mRequest); synchronized (mInterruptionLock) { if (mRequest.isAborted() || mInterrupted) { mRequest = null; throw new InterruptedException(); } mRequest = null; } if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new WrongHttpResponseCode(response); } String responseStr = HTTPUtils.getStringFromResponse(response); StringTokenizer responseSplit = new StringTokenizer(responseStr, ":"); ConnectionResult result = new ConnectionResult(); try { result.sessionId = responseSplit.nextToken(); if (TextUtils.isEmpty(result.sessionId)) { throw new WrongSocketIOResponse("Empty socket io session id"); } result.timeout = getIntOrAbsetFromString(responseSplit.nextToken()); result.heartbeat = getIntOrAbsetFromString(responseSplit.nextToken()); ImmutableSet<String> types = getTypesFromString(responseSplit.nextToken()); if (!types.contains("websocket")) { throw new WrongSocketIOResponse("Websocket not found in server response"); } } catch (NoSuchElementException e) { throw new WrongSocketIOResponse("Not enough color separated values in response", e); } result.socketUri = new Uri.Builder().scheme("ws").encodedAuthority(uri.getEncodedAuthority()) .path(uri.getPath()).appendPath("websocket").appendPath(result.sessionId).build(); return result; }