| | |
| | | import android.util.Log; |
| | | |
| | | import com.anyun.im_lib.interf.IMSClientInteface; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonArray; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.JsonParser; |
| | | import com.google.gson.reflect.TypeToken; |
| | | |
| | | |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.Vector; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | private Vector<String> convertHosts(String hosts) { |
| | | Log.i(TAG, "convertHosts: "+hosts); |
| | | if (hosts != null && hosts.length() > 0) { |
| | | JsonArray hostArray = JsonParser.parseString(hosts).getAsJsonArray(); |
| | | if (null != hostArray && hostArray.size() > 0) { |
| | | Vector<String> serverUrlList = new Vector<String>(); |
| | | JsonObject host; |
| | | for (int i = 0; i < hostArray.size(); i++) { |
| | | host = JsonParser.parseString(hostArray.get(i).toString()).getAsJsonObject(); |
| | | serverUrlList.add(host.get("host") + " " |
| | | + host.get("port")); |
| | | } |
| | | return serverUrlList; |
| | | |
| | | Vector<String> serverUrlList = new Vector<>(); |
| | | JsonArray jsonArray =JsonParser.parseString(hosts).getAsJsonArray(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JsonObject host = jsonArray.get(i).getAsJsonObject(); |
| | | String hostName = host.get("host").getAsString(); |
| | | int port = host.get("port").getAsInt(); |
| | | |
| | | Log.i(TAG, "convertHosts: hostname="+hostName+" port="+port); |
| | | serverUrlList.add(hostName+" "+port); |
| | | } |
| | | return serverUrlList; |
| | | |
| | | |
| | | |
| | | } |