// Requests & returns a TURN ICE Server based on a request URL. Must be run // off the main thread! private PeerConnection.IceServer requestTurnServer(string url) { try { URLConnection connection = (new URL(url)).OpenConnection(); connection.AddRequestProperty("user-agent", "Mozilla/5.0"); connection.AddRequestProperty("origin", "https://apprtc.appspot.com"); string response = drainStream(connection.InputStream); JSONObject responseJSON = new JSONObject(response); string uri = responseJSON.GetJSONArray("uris").GetString(0); string username = responseJSON.GetString("username"); string password = responseJSON.GetString("password"); return(new PeerConnection.IceServer(uri, username, password)); } catch (JSONException e) { throw new Exception("Error", e); } catch (IOException e) { throw new Exception("Error", e); } }