diff --git a/resource/config/config.go b/resource/config/config.go index 6b802aeb76fd710d79f421971a5ae571aaf07a06..4dbc40b1fa97425bf9938758b519a05c0f71b245 100644 --- a/resource/config/config.go +++ b/resource/config/config.go @@ -120,6 +120,12 @@ type AgoraConfig struct { CUSTOMER_SECRET string } +//腾讯TRTC +type TRTCConfig struct { + APP_ID int + APP_CERTIFICATE string +} + //匹配的配置 type MatchConfig struct { //一开始匹配的默认时长(单位:秒) @@ -323,6 +329,7 @@ var rongyunData RongyunConfig var tencentyunData TencentyunConfig var emasData EmasConfig var agora AgoraConfig +var trtc TRTCConfig var matchData MatchConfig var onlineData OnlineConfig var sessionData SessionConfig @@ -570,6 +577,10 @@ func GetUrlConfig() URLConfig { return urlConfig } +func GetTRTCConfig() TRTCConfig { + return trtc +} + func init() { str, _ := os.Getwd() mylogrus.MyLog.Info(str) @@ -655,6 +666,10 @@ func init() { mylogrus.MyLog.Fatal(err) } + if err := conf.Section("TRTC").MapTo(&trtc); err != nil { + mylogrus.MyLog.Fatal(err) + } + if err := conf.Section("MATCH").MapTo(&matchData); err != nil { mylogrus.MyLog.Fatal(err) } diff --git a/sdk/trtc/trtc.go b/sdk/trtc/trtc.go index 8ada5a39de79a905b2c0b677fbb6ca0cb3086ad6..845585a86aeac26834769738c9bb012a9ea7337a 100644 --- a/sdk/trtc/trtc.go +++ b/sdk/trtc/trtc.go @@ -3,15 +3,14 @@ package trtc import ( "fmt" "git.hilo.cn/hilo-common/mylogrus" + "git.hilo.cn/hilo-common/resource/config" ) //创建群组的TRTC通道,token有效时长:一个星期 -func CreateGroupTRTCUserSig(uid uint64) string { - appId := 1400548270 - appSecret := "321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8" +func CreateGroupTRTCUserSig(uid uint64, config config.TRTCConfig) string { expireTimeInSeconds := 60 * 60 * 24 * 7 //一个星期 - sig, err := GenUserSig(appId, appSecret, fmt.Sprintf("%d", uid), expireTimeInSeconds) + sig, err := GenUserSig(config.APP_ID, config.APP_CERTIFICATE, fmt.Sprintf("%d", uid), expireTimeInSeconds) if err != nil { mylogrus.MyLog.Errorf("CreateGroupTRTCUserSig uid:%d, err:%v", uid, err) }