Commit 55f05c88 authored by chenweijian's avatar chenweijian

trtc

parent fa66af14
...@@ -156,3 +156,11 @@ var GROUP_NOBLE4_JOIN_LIMIT uint = 1000 ...@@ -156,3 +156,11 @@ var GROUP_NOBLE4_JOIN_LIMIT uint = 1000
var GROUP_ROLE_PERSONAL_VIEW_LIMIT = 5 var GROUP_ROLE_PERSONAL_VIEW_LIMIT = 5
var GROUP_MANAGER_LIMIT uint = 30 var GROUP_MANAGER_LIMIT uint = 30
var GROUP_ADMIN_LIMIT uint = 50 var GROUP_ADMIN_LIMIT uint = 50
type GroupProvider = uint8
const (
// 群组声音供应商
GroupProvider_SW GroupProvider = 1 // 声网
GroupProvider_TRTC GroupProvider = 2 // 腾讯trtc
)
...@@ -221,6 +221,7 @@ type GroupChannelId struct { ...@@ -221,6 +221,7 @@ type GroupChannelId struct {
Token string `json:"token"` Token string `json:"token"`
AgoraId uint32 `json:"agoraId"` AgoraId uint32 `json:"agoraId"`
MicNumType uint8 `json:"micNumType"` MicNumType uint8 `json:"micNumType"`
Provider uint8 `json:"provider"` // 供应商 1.声网 2.腾讯trtc
} }
//国籍视图 //国籍视图
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"git.hilo.cn/hilo-common/rpc" "git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/sdk/agora" "git.hilo.cn/hilo-common/sdk/agora"
"git.hilo.cn/hilo-common/sdk/tencentyun" "git.hilo.cn/hilo-common/sdk/tencentyun"
"git.hilo.cn/hilo-common/sdk/trtc"
"git.hilo.cn/hilo-common/utils" "git.hilo.cn/hilo-common/utils"
"gorm.io/gorm" "gorm.io/gorm"
"hilo-group/_const/enum/group_e" "hilo-group/_const/enum/group_e"
...@@ -115,7 +116,7 @@ func (s *GroupService) LeaveGroupMember(model *domain.Model, groupId string, use ...@@ -115,7 +116,7 @@ func (s *GroupService) LeaveGroupMember(model *domain.Model, groupId string, use
} }
//进入房间, 返回channelId, err //进入房间, 返回channelId, err
func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid string, password, imei, ip string) (string, string, error) { func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid string, password, imei, ip string, provider group_e.GroupProvider) (string, string, error) {
var channelId string var channelId string
var token string var token string
err := s.svc.Transactional(func() error { err := s.svc.Transactional(func() error {
...@@ -171,7 +172,11 @@ func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid strin ...@@ -171,7 +172,11 @@ func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid strin
if err != nil { if err != nil {
return err return err
} }
if provider == group_e.GroupProvider_TRTC {
token = trtc.CreateGroupTRTCUserSig(userId)
} else {
channelId, token, err = agora.CreateGroupAgora(groupInfo.ChannelId, uint32(userId)) channelId, token, err = agora.CreateGroupAgora(groupInfo.ChannelId, uint32(userId))
}
if err != nil { if err != nil {
return err return err
} else { } else {
......
...@@ -1751,7 +1751,12 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1751,7 +1751,12 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
} }
model.Log.Infof("GroupIn ip userId:%v,imGroupId:%v,ip:%v,imei:%v", userId, groupId, ip, imei) model.Log.Infof("GroupIn ip userId:%v,imGroupId:%v,ip:%v,imei:%v", userId, groupId, ip, imei)
if channelId, token, err := group_s.NewGroupService(myContext).GroupIn(userId, externalId, groupId, password, imei, ip); err != nil { provider := group_e.GroupProvider_SW
if gi.Code == "70740667" {
provider = group_e.GroupProvider_TRTC
}
if channelId, token, err := group_s.NewGroupService(myContext).GroupIn(userId, externalId, groupId, password, imei, ip, provider); err != nil {
return myContext, err return myContext, err
} else { } else {
// 加入房间缓存 // 加入房间缓存
...@@ -1767,6 +1772,7 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1767,6 +1772,7 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
Token: token, Token: token,
AgoraId: uint32(userId), AgoraId: uint32(userId),
MicNumType: gi.MicNumType, MicNumType: gi.MicNumType,
Provider: provider,
}) })
// v2.26及以后,客户端自己加TIM群,不再由服务器代加 // v2.26及以后,客户端自己加TIM群,不再由服务器代加
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment