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
5bbb19d9
Commit
5bbb19d9
authored
Sep 03, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature/group room living
parent
8013f67e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
room.go
domain/model/group_m/room.go
+14
-14
No files found.
domain/model/group_m/room.go
View file @
5bbb19d9
...
...
@@ -50,14 +50,14 @@ func RoomLivingExpire(model *domain.Model, groupUid string, userId uint64) {
model
.
Log
.
Infof
(
"room RoomLivingExpire userId:%v, groupUid:%v"
,
userId
,
groupUid
)
//
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
i
,
err
:=
redisCli
.
GetRedis
()
.
ZAdd
(
context
.
Background
(),
key
,
&
redis2
.
Z
{
_
,
err
:=
model
.
RedisCluster
.
ZAdd
(
context
.
Background
(),
key
,
&
redis2
.
Z
{
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
getMemberStr
(
groupUid
,
userId
),
})
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"RoomLivingExpire ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
}
else
{
model
.
Log
.
Infof
(
"RoomLivingExpire ZAdd key:%v, groupUid:%v, userId:%v result:%v"
,
key
,
groupUid
,
userId
,
i
)
//
model.Log.Infof("RoomLivingExpire ZAdd key:%v, groupUid:%v, userId:%v result:%v", key, groupUid, userId, i)
}
}
...
...
@@ -70,14 +70,14 @@ func RoomLivingIn(model *domain.Model, groupUid string, userId uint64, externalI
}
//
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
i
,
err
:=
redisCli
.
GetRedis
()
.
ZAdd
(
context
.
Background
(),
key
,
&
redis2
.
Z
{
_
,
err
:=
model
.
RedisCluster
.
ZAdd
(
context
.
Background
(),
key
,
&
redis2
.
Z
{
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
getMemberStr
(
groupUid
,
userId
),
})
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"UpdateRoomLiving ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
}
else
{
model
.
Log
.
Infof
(
"UpdateRoomLiving ZAdd key:%v, groupUid:%v, userId:%v result:%v"
,
key
,
groupUid
,
userId
,
i
)
//
model.Log.Infof("UpdateRoomLiving ZAdd key:%v, groupUid:%v, userId:%v result:%v", key, groupUid, userId, i)
}
go
func
(
myContext
*
mycontext
.
MyContext
,
groupId
string
)
{
...
...
@@ -112,11 +112,11 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
if
err
:=
model
.
Redis
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
if
err
:=
model
.
Redis
Cluster
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
data
,
err
:=
redisCli
.
GetRedis
()
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
data
,
err
:=
model
.
RedisCluster
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
...
...
@@ -125,12 +125,12 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
for
i
,
_
:=
range
data
{
gid
,
uid
:=
analysisMemberStr
(
data
[
i
])
if
uid
==
userId
&&
(
groupId
==
""
||
gid
==
groupId
)
{
if
_
,
err
:=
redisCli
.
GetRedis
()
.
ZRem
(
context
.
Background
(),
key
,
getMemberStr
(
gid
,
uid
))
.
Result
();
err
!=
nil
{
if
_
,
err
:=
model
.
RedisCluster
.
ZRem
(
context
.
Background
(),
key
,
getMemberStr
(
gid
,
uid
))
.
Result
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"RoomLivingLeave ZRem key:%s, groupId:%s, userId:%d, err:%v"
,
key
,
gid
,
uid
,
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
else
{
groupIds
=
append
(
groupIds
,
gid
)
model
.
Log
.
Infof
(
"RoomLivingLeave ZRem success key:%s, groupId:%s, userId:%d"
,
key
,
gid
,
uid
)
//
model.Log.Infof("RoomLivingLeave ZRem success key:%s, groupId:%s, userId:%d", key, gid, uid)
}
// 发信令,让前端重新拉取,接受容错,
...
...
@@ -272,11 +272,11 @@ func RoomLivingExistsUserId(groupUid string) ([]uint64, error) {
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
var
model
=
domain
.
CreateModelNil
()
if
err
:=
model
.
Redis
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
if
err
:=
model
.
Redis
Cluster
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
groupUserIdstrs
,
err
:=
redisCli
.
GetRedis
()
.
ZRevRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
groupUserIdstrs
,
err
:=
model
.
RedisCluster
.
ZRevRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
...
...
@@ -300,11 +300,11 @@ func RoomLivingUserIdFilter(userIds []mysql.ID) (map[mysql.ID]string, error) {
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
model
:=
domain
.
CreateModelNil
()
if
err
:=
model
.
Redis
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
if
err
:=
model
.
Redis
Cluster
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
groupUserIdstrs
,
err
:=
redisCli
.
GetRedis
()
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
groupUserIdstrs
,
err
:=
model
.
RedisCluster
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
...
...
@@ -325,12 +325,12 @@ func RoomLivingUserIdFilter(userIds []mysql.ID) (map[mysql.ID]string, error) {
func
RoomLivingExistsGroup
(
model
*
domain
.
Model
)
(
map
[
string
]
map
[
uint64
]
struct
{},
error
)
{
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
if
err
:=
model
.
Redis
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
if
err
:=
model
.
Redis
Cluster
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireMinute
,
10
))
.
Err
();
err
!=
nil
{
model
.
Log
.
Infof
(
"RoomLivingExistsGroup: err:%v"
,
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
groupUserIdstrs
,
err
:=
redisCli
.
GetRedis
()
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
groupUserIdstrs
,
err
:=
model
.
RedisCluster
.
ZRange
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
...
...
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