Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
a4c43c34
You need to sign in or sign up before continuing.
Commit
a4c43c34
authored
Apr 12, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:动态初始化trtc房间
parent
4e497849
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
groupInfo.go
domain/model/group_m/groupInfo.go
+15
-0
group_op.go
route/group_r/group_op.go
+14
-4
No files found.
domain/model/group_m/groupInfo.go
View file @
a4c43c34
...
...
@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/utils"
"github.com/bluele/gcache"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-group/_const/enum/group_e"
"hilo-group/myerr"
"hilo-group/myerr/bizerr"
...
...
@@ -575,3 +576,17 @@ func IsUseTRTC(model *domain.Model, imGroupId string) bool {
}
return
count
>
0
}
type
GroupTrtc
struct
{
mysql
.
Entity
ImGroupId
mysql
.
Str
}
// 初始化trtc房间
func
InitTRTC
(
model
*
domain
.
Model
,
imGroupId
string
)
error
{
if
err
:=
model
.
DB
()
.
Model
(
GroupTrtc
{})
.
Clauses
(
clause
.
OnConflict
{
DoNothing
:
true
})
.
Create
(
&
GroupTrtc
{
ImGroupId
:
imGroupId
})
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"InitTRTC err:%v, groupId:%s"
,
err
,
imGroupId
)
return
err
}
return
nil
}
route/group_r/group_op.go
View file @
a4c43c34
...
...
@@ -1753,6 +1753,20 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
provider
:=
group_e
.
GroupProvider_SW
if
group_m
.
IsUseTRTC
(
model
,
groupId
)
{
provider
=
group_e
.
GroupProvider_TRTC
}
else
{
if
time
.
Now
()
.
Unix
()
>
1683820800
{
// todo 1683820800=5月2号,等过审再修改
roomUser
,
err
:=
group_m
.
GetRoomOnlineUser
(
myContext
,
groupId
)
if
err
==
nil
&&
roomUser
.
Total
==
0
{
if
err
:=
group_m
.
InitTRTC
(
model
,
groupId
);
err
!=
nil
{
return
myContext
,
err
}
provider
=
group_e
.
GroupProvider_TRTC
model
.
Log
.
Infof
(
"auto shift trtc room groupId:%v,%+v-%v"
,
groupId
,
roomUser
,
err
)
}
}
}
if
provider
==
group_e
.
GroupProvider_TRTC
{
// 版本升级提示,旧版本(3.6.0以下),提示升级
_
,
major
,
minor
,
_
,
err
:=
req
.
GetAppVersion
(
c
)
if
err
!=
nil
{
...
...
@@ -1761,10 +1775,6 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
if
(
major
<
3
)
||
(
major
==
3
&&
minor
<
6
)
{
return
myContext
,
bizerr
.
UpgradeRequired
}
provider
=
group_e
.
GroupProvider_TRTC
}
else
{
roomUser
,
err
:=
group_m
.
GetRoomOnlineUser
(
myContext
,
groupId
)
model
.
Log
.
Infof
(
"group_m.GetRoomOnlineUser %+v-%v"
,
roomUser
,
err
)
}
if
channelId
,
token
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GroupIn
(
userId
,
externalId
,
groupId
,
password
,
imei
,
ip
,
provider
);
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment