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
Compare Revisions
master...feature/group_room_living
Source
feature/group_room_living
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (2)
group_room_living
· ba1dd608
JiebinHu
authored
Sep 03, 2023
ba1dd608
Update room.go
· a5dd2a46
iamhujiebin
authored
Sep 03, 2023
a5dd2a46
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 @
a5dd2a46
...
@@ -50,14 +50,14 @@ func RoomLivingExpire(model *domain.Model, groupUid string, userId uint64) {
...
@@ -50,14 +50,14 @@ func RoomLivingExpire(model *domain.Model, groupUid string, userId uint64) {
model
.
Log
.
Infof
(
"room RoomLivingExpire userId:%v, groupUid:%v"
,
userId
,
groupUid
)
model
.
Log
.
Infof
(
"room RoomLivingExpire userId:%v, groupUid:%v"
,
userId
,
groupUid
)
//
//
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
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
()),
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
getMemberStr
(
groupUid
,
userId
),
Member
:
getMemberStr
(
groupUid
,
userId
),
})
.
Result
()
})
.
Result
()
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"RoomLivingExpire ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
model
.
Log
.
Errorf
(
"RoomLivingExpire ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
}
else
{
}
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
...
@@ -70,14 +70,14 @@ func RoomLivingIn(model *domain.Model, groupUid string, userId uint64, externalI
}
}
//
//
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
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
()),
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
getMemberStr
(
groupUid
,
userId
),
Member
:
getMemberStr
(
groupUid
,
userId
),
})
.
Result
()
})
.
Result
()
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"UpdateRoomLiving ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
model
.
Log
.
Errorf
(
"UpdateRoomLiving ZAdd key:%v, groupUid:%v, userId:%v, err:%v"
,
key
,
groupUid
,
userId
,
err
)
}
else
{
}
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
)
{
go
func
(
myContext
*
mycontext
.
MyContext
,
groupId
string
)
{
...
@@ -112,11 +112,11 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
...
@@ -112,11 +112,11 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
//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
)
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
{
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
...
@@ -125,12 +125,12 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
...
@@ -125,12 +125,12 @@ func roomLivingLeave(model *domain.Model, userId uint64, groupId string) ([]stri
for
i
,
_
:=
range
data
{
for
i
,
_
:=
range
data
{
gid
,
uid
:=
analysisMemberStr
(
data
[
i
])
gid
,
uid
:=
analysisMemberStr
(
data
[
i
])
if
uid
==
userId
&&
(
groupId
==
""
||
gid
==
groupId
)
{
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
)
model
.
Log
.
Errorf
(
"RoomLivingLeave ZRem key:%s, groupId:%s, userId:%d, err:%v"
,
key
,
gid
,
uid
,
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
else
{
}
else
{
groupIds
=
append
(
groupIds
,
gid
)
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) {
...
@@ -272,11 +272,11 @@ func RoomLivingExistsUserId(groupUid string) ([]uint64, error) {
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
var
model
=
domain
.
CreateModelNil
()
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
)
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
{
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
...
@@ -300,11 +300,11 @@ func RoomLivingUserIdFilter(userIds []mysql.ID) (map[mysql.ID]string, error) {
...
@@ -300,11 +300,11 @@ func RoomLivingUserIdFilter(userIds []mysql.ID) (map[mysql.ID]string, error) {
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
model
:=
domain
.
CreateModelNil
()
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
)
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
{
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
...
@@ -325,12 +325,12 @@ func RoomLivingUserIdFilter(userIds []mysql.ID) (map[mysql.ID]string, error) {
...
@@ -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
)
{
func
RoomLivingExistsGroup
(
model
*
domain
.
Model
)
(
map
[
string
]
map
[
uint64
]
struct
{},
error
)
{
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
key
:=
redis_key
.
GetPrefixGroupRoomLiving
()
//if err := redisCli.ClearExpired(key, expireMinute); err != nil {
//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
)
model
.
Log
.
Infof
(
"RoomLivingExistsGroup: err:%v"
,
err
)
return
nil
,
myerr
.
WrapErr
(
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
{
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
...
...