goupan
2024-04-03 5506e9a45e717ffcb67ec313b5a4e8206d9b3a39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cn.stylefeng.roses.kernel.im.starter;
 
import cn.stylefeng.roses.kernel.im.api.ImServerApi;
import cn.stylefeng.roses.kernel.im.api.expander.ImConfigExpander;
import cn.stylefeng.roses.kernel.im.api.pojo.RongCloudProperties;
import cn.stylefeng.roses.kernel.im.rongcloud.RongCloudImServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
/**
 * IM的自动配置类
 */
@Configuration
public class GunsImAutoConfiguration {
 
    /**
     * IM发送器的配置
     */
    @Bean
    @ConditionalOnMissingBean(ImServerApi.class)
    public ImServerApi imServerApi() {
        // 融云环境配置
        RongCloudProperties rongCloudProperties = new RongCloudProperties();
 
        // 配置默认从系统配置表读取
        rongCloudProperties.setAppKey(ImConfigExpander.getRongCouldAppKey());
        rongCloudProperties.setAppSecret(ImConfigExpander.getRongCouldAppSecret());
 
        return new RongCloudImServer(rongCloudProperties);
    }
 
}