Esempio n. 1
0
        internal static string GetAPIHost(AVRegion region)
        {
            string[] apiHostCollections = { APIAddressCN, APIAddressUS };
            int      regionIndex        = (int)region;

            Node = (AVNode)regionIndex;
            if (regionIndex < 0 || regionIndex > apiHostCollections.Length)
            {
                throw new Exception("所选的节点不在 LeanCloud 的支持范围之内,请查阅文档。");
            }
            string targetHost = apiHostCollections[regionIndex];

            return(targetHost);
        }
Esempio n. 2
0
        /// <summary>
        /// 切换 LeanCloud 节点
        /// </summary>
        /// <param name="region">节点</param>
        public static void SwitchAVRegion(AVRegion region)
        {
            string targetHost = GetAPIHost(region);

            HostName = new Uri(targetHost);
        }
Esempio n. 3
0
        /// <summary>
        /// 初始化 AVClient,所有 AVOS Cloud 的请求都是通过这个类去实现,所以在使用 sdk 之前,必须显示地调用Initialize方法。
        /// </summary>
        /// <param name="applicationId">Application ID 可以从 AVOS Cloud 控制台中->设置 找到。</param>
        /// <param name="applicationKey">App Key 可以从 AVOS Cloud 控制台中->设置 找到。</param>
        /// <param name="region">目前仅支持CN和US,默认值是CN。</param>
        public static void Initialize(string applicationId, string applicationKey, AVRegion region)
        {
            string targetHost = GetAPIHost(region);

            Initialize(applicationId, applicationKey, targetHost);
        }