From 655f6c9d9371a6e87b339190ded7fffe6c907599 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Mon, 3 Apr 2023 10:46:59 +0800 Subject: [PATCH] trtc config --- resource/config/config.go | 15 +++++++++++++++ sdk/trtc/trtc.go | 7 +++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/resource/config/config.go b/resource/config/config.go index 6b802ae..4dbc40b 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 8ada5a3..845585a 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) } -- 2.22.0