/**
 * 融云 Server API java 客户端
 * create by kitName
 * create datetime : 2017-06-05
 * <p>
 * v2.0.1
 */
package io.rong;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import io.rong.methods.chatroom.*;
import io.rong.methods.conversation.Conversation;
import io.rong.methods.group.Group;
import io.rong.methods.message.Message;
import io.rong.methods.sensitive.SensitiveWord;
import io.rong.methods.sensitive.Wordfilter;
import io.rong.methods.user.User;
import io.rong.methods.push.Push;

public class RongCloud {

	private static ConcurrentHashMap<String, RongCloud> rongCloud = new ConcurrentHashMap<String, RongCloud>();

	public User user;
	public Message message;
	public Wordfilter wordfilter;
	public SensitiveWord sensitiveword;
	public Group group;
	public Chatroom chatroom;
	public Conversation conversation;
	public Push push;
	public final RongCloudConfig config;

	public RongCloudConfig getConfig() {
		return this.config;
	}

	private RongCloud(String appKey, String appSecret, RongCloudConfig config) {
		user = new User(appKey, appSecret,this);
		message = new Message(appKey, appSecret);
		message.setRongCloud(this);
		wordfilter = new Wordfilter(appKey, appSecret);
		wordfilter.setRongCloud(this);
		sensitiveword = new SensitiveWord(appKey, appSecret);
		sensitiveword.setRongCloud(this);
		group = new Group(appKey, appSecret, this);
		chatroom = new Chatroom(appKey, appSecret,this);
		chatroom.setRongCloud(this);
		conversation = new Conversation(appKey,appSecret);
		conversation.setRongCloud(this);
		push = new Push(appKey,appSecret);
		push.setRongCloud(this);
		this.config = config;
	}

	/**
	 * 获取访问北京数据中心的实例
	 * @param appKey
	 * @param appSecret
	 * @return
	 */
	public static RongCloud getInstance(String appKey, String appSecret) {
		return getInstance(appKey, appSecret, RongCloudConfig.DefaultConfig);
	}
	/**
	 * 获取访问新加坡数据中心的实例
	 * @param appKey
	 * @param appSecret
	 * @return
	 */
	public static RongCloud getSingaporeInstance(String appKey, String appSecret) {
		return getInstance(appKey, appSecret, RongCloudConfig.SingaporeConfig);
	}
	/**
	 * 自定义访问实例
	 * @param appKey
	 * @param appSecret
	 * @param config
	 * @return
	 */
	public static RongCloud getInstance(String appKey, String appSecret, RongCloudConfig config) {
		if(null == rongCloud.get(appKey)) {
			RongCloud rc = new RongCloud(appKey, appSecret, config);
			rongCloud.putIfAbsent(appKey, rc);
		}
		return rongCloud.get(appKey);
	}
	
	/**
	 * 自定义 API 地址
	 * */
	@Deprecated
	public static RongCloud getInstance(String appKey, String appSecret,String api) {
		return getInstance(appKey, appSecret, new RongCloudConfig(api));
	}
	/**
	 * 自定义 api 支持备用域名
	 * @param appKey
	 * @param appSecret
	 * @param api 主 API 地址
	 * @param apiBackUp 备用 API 地址列表
	 * */
	@Deprecated
	public static RongCloud getInstance(String appKey, String appSecret,String api,List<String> apiBackUp) {
		if(apiBackUp==null) {
			apiBackUp = new ArrayList<String>();
		}
		apiBackUp.add(api);
		return getInstance(appKey, appSecret, new RongCloudConfig(api));
	}

}
@@ -2685,24 +2685,26 @@
 g(api));%0A%09%7D%0A
+%09%0A
 %09/**%0A%09 * %E8%87%AA%E5%AE%9A%E4%B9%89
@@ -2715,16 +2715,21 @@
  %E6%94%AF%E6%8C%81%E5%A4%87%E7%94%A8%E5%9F%9F%E5%90%8D%0A
+%09 * %0A
 %09 * @par
@@ -2774,16 +2774,22 @@
 ram api 
+      
 %E4%B8%BB API %E5%9C%B0%E5%9D%80
@@ -2823,18 +2823,16 @@
 I %E5%9C%B0%E5%9D%80%E5%88%97%E8%A1%A8%0A%09
- *
  */%0A%09@De
@@ -2901,32 +2901,33 @@
 tring appSecret,
+ 
 String api,List%3C
@@ -2921,16 +2921,17 @@
 ing api,
+ 
 List%3CStr
@@ -2954,33 +2954,108 @@
 %7B%0A%09%09
-if(apiBackUp==null) %7B%0A%09%09%09
+List%3CString%3E apiList = new ArrayList%3CString%3E();%0A%09%09if (api != null) %7B%0A%09%09%09apiList.add(api);%0A%09%09%7D%0A%09%09if (
 apiB
@@ -3064,60 +3064,132 @@
 kUp 
+!
 = n
-ew ArrayList%3CString%3E();%0A%09%09%7D%0A
+ull && apiBackUp.size() %3E 0) %7B%0A%09%09%09for (String item : apiBackUp) %7B%0A%09%09%09%09if (item != null)%0A%09%09%09
 %09%09api
-BackUp.add(api);
+List.add(item);%0A%09%09%09%7D%0A%09%09%7D
 %0A%09%09r
@@ -3248,17 +3248,23 @@
 nfig(api
+List
 ));%0A%09%7D
+%0A%09
 %0A%0A%7D

修改自定义 API 域名 + 备用域名的逻辑