Esempio n. 1
0
        /// <summary>
        /// 使用融云通信
        /// </summary>
        /// <param name="services"></param>
        /// <param name="setConfig"></param>
        public static IServiceCollection AddRongCloud(this IServiceCollection services, Action <RongCloudConfig> setConfig)
        {
            var config = new RongCloudConfig();

            setConfig?.Invoke(config);
            return(services.AddRongCloud(config));
        }
Esempio n. 2
0
        public RongCloudSmsTests()
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true)
                                .Build();

            _config = configuration.GetSection("SMS:RongCloud").Get <RongCloudConfig>();
            _client = new RongCloudClient(_config);
        }
Esempio n. 3
0
        public RongCloudClient(RongCloudConfig config, Action <Exception> exceptionHandler = null)
        {
            _config      = config ?? throw new ArgumentNullException(nameof(config));
            _rongAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy       = HttpApi.Create <IRongCloudSmsApis>();

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
        public void RongCloudSetAppKeyTest()
        {
            try
            {
                var appKey = "";

                var config = new RongCloudConfig
                {
                    AppKey = appKey
                };
            }
            catch (Exception ex)
            {
                Assert.Equal(ex.Message, "rongcloud appkey must not be null or empty");
            }
        }
Esempio n. 5
0
 public static IServiceCollection AddRongCloud(this IServiceCollection services, RongCloudConfig config)
 {
     services.AddSingleton <ILayIMAppInfo>(config);
     services.AddSingleton <ILayIMServer, RongCloudServer>();
     services.AddSingleton <IApiActionFilter, ApiFilter>();
     return(services);
 }