Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-userCenter
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-userCenter
Commits
89a6028d
Commit
89a6028d
authored
Jul 25, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取用户在房间的最后一次心跳
parent
774b5480
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
main.go
main.go
+10
-0
roomManager.go
manager/roomManager.go
+11
-0
userCenter.proto
protocol/userCenter.proto
+11
-0
No files found.
main.go
View file @
89a6028d
...
@@ -285,6 +285,16 @@ func (s *server) RoomHeartbeat(ctx context.Context, in *userCenter.RoomHeartbeat
...
@@ -285,6 +285,16 @@ func (s *server) RoomHeartbeat(ctx context.Context, in *userCenter.RoomHeartbeat
},
nil
},
nil
}
}
func
(
s
*
server
)
GetLastRoomHeartbeat
(
ctx
context
.
Context
,
in
*
userCenter
.
GetLastRoomHeartbeatMessage
)
(
*
userCenter
.
GetLastRoomHeartbeatMessageResp
,
error
)
{
ts
,
err
:=
roomManager
.
GetLastRoomUserHeartbeat
(
in
.
GetUid
(),
in
.
GetGroupId
())
if
err
!=
nil
{
return
nil
,
err
}
return
&
userCenter
.
GetLastRoomHeartbeatMessageResp
{
Timestamp
:
ts
,
},
nil
}
func
realBroadcast
(
addr
string
,
uids
[]
uint64
,
msg
*
userCenter
.
BroadcastMessage
)
{
func
realBroadcast
(
addr
string
,
uids
[]
uint64
,
msg
*
userCenter
.
BroadcastMessage
)
{
mylogrus
.
MyLog
.
Infof
(
"Broadcasting: Addr %s: users: %v"
,
addr
,
uids
)
mylogrus
.
MyLog
.
Infof
(
"Broadcasting: Addr %s: users: %v"
,
addr
,
uids
)
...
...
manager/roomManager.go
View file @
89a6028d
...
@@ -54,6 +54,17 @@ func (m *RoomManager) UpdateRoomUser(uid uint64, groupId string) error {
...
@@ -54,6 +54,17 @@ func (m *RoomManager) UpdateRoomUser(uid uint64, groupId string) error {
return
err
return
err
}
}
// 获取用户在房间的最后一次心跳
func
(
m
*
RoomManager
)
GetLastRoomUserHeartbeat
(
uid
uint64
,
groupId
string
)
(
int64
,
error
)
{
key
:=
getRoomUserKey
(
groupId
)
tx
,
err
:=
m
.
RedisClient
.
ZScore
(
m
.
Ctx
,
key
,
fmt
.
Sprintf
(
"%d"
,
uid
))
.
Result
()
if
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"GetLastRoomUserHeartbeat fail:%v"
,
err
)
return
0
,
err
}
return
int64
(
tx
),
err
}
func
(
m
*
RoomManager
)
GetAll
()
*
map
[
string
]
string
{
func
(
m
*
RoomManager
)
GetAll
()
*
map
[
string
]
string
{
//ctx, _ := context.WithTimeout(m.Ctx, time.Millisecond*500)
//ctx, _ := context.WithTimeout(m.Ctx, time.Millisecond*500)
//result := m.RedisClient.Get(ctx, field)
//result := m.RedisClient.Get(ctx, field)
...
...
protocol/userCenter.proto
View file @
89a6028d
...
@@ -112,6 +112,16 @@ message RoomHeartbeatMessageRsp {
...
@@ -112,6 +112,16 @@ message RoomHeartbeatMessageRsp {
uint32
status
=
1
;
uint32
status
=
1
;
}
}
// 获取房间内最后一次心跳
message
GetLastRoomHeartbeatMessage
{
uint64
uid
=
1
;
string
groupId
=
2
;
}
message
GetLastRoomHeartbeatMessageResp
{
int64
timestamp
=
1
;
}
service
Router
{
service
Router
{
rpc
route
(
RouteMessage
)
returns
(
RouteMessageRsp
)
{}
rpc
route
(
RouteMessage
)
returns
(
RouteMessageRsp
)
{}
rpc
kickUser
(
KickMessage
)
returns
(
KickMessageRsp
)
{}
rpc
kickUser
(
KickMessage
)
returns
(
KickMessageRsp
)
{}
...
@@ -126,4 +136,5 @@ service User {
...
@@ -126,4 +136,5 @@ service User {
rpc
enterRoom
(
EnterRoomMessage
)
returns
(
EnterRoomMessageRsp
)
{}
rpc
enterRoom
(
EnterRoomMessage
)
returns
(
EnterRoomMessageRsp
)
{}
rpc
leaveRoom
(
LeaveRoomMessage
)
returns
(
LeaveRoomMessageRsp
)
{}
rpc
leaveRoom
(
LeaveRoomMessage
)
returns
(
LeaveRoomMessageRsp
)
{}
rpc
roomHeartbeat
(
RoomHeartbeatMessage
)
returns
(
RoomHeartbeatMessageRsp
)
{}
rpc
roomHeartbeat
(
RoomHeartbeatMessage
)
returns
(
RoomHeartbeatMessageRsp
)
{}
rpc
getLastRoomHeartbeat
(
GetLastRoomHeartbeatMessage
)
returns
(
GetLastRoomHeartbeatMessageResp
)
{}
}
}
\ No newline at end of file
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