Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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-common
Commits
2edfa2a3
Commit
2edfa2a3
authored
Apr 18, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
羊羊两个ws
parent
ac71646a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
1 deletion
+85
-1
userProxy.proto
protocol/userProxy.proto
+18
-0
user_center_coder.go
rpc/user_center_coder.go
+2
-0
user_center_func.go
rpc/user_center_func.go
+64
-0
utils_test.go
script/utils/utils_test.go
+1
-1
No files found.
protocol/userProxy.proto
View file @
2edfa2a3
...
...
@@ -364,4 +364,22 @@ message GlobalGameBanner {
uint64
diamond
=
4
;
string
bannerUrl
=
5
;
uint64
gameId
=
6
;
// 1.ludo 2.uno 3.dice 4.lucky wheel 5.lucky box 6.fruit 7.slot
}
/* id == 147 羊羊匹配成功 */
message
SheepMatchSuccess
{
uint64
match_id
=
1
;
User
userId1
=
2
;
User
userId2
=
3
;
}
message
SheepGamePlayer
{
User
user
=
1
;
bool
IsWin
=
2
;
}
/* id == 148 羊羊游戏结果 */
message
SheepGameResult
{
uint64
match_id
=
1
;
repeated
SheepGamePlayer
players
=
2
;
}
\ No newline at end of file
rpc/user_center_coder.go
View file @
2edfa2a3
...
...
@@ -61,6 +61,8 @@ const (
MsgRoomInviteMember
=
144
// 邀请用户成为房间会员
MsgDiamondChange
=
145
// 钻石数变化
MsgTypeGlobalGameBanner
=
146
// 游戏横幅
MsgTypeSheepGameMatchSuccess
=
147
// 羊羊匹配成功
MsgTypeSheepGameResult
=
148
// 羊羊游戏结果
)
const
(
...
...
rpc/user_center_func.go
View file @
2edfa2a3
...
...
@@ -217,3 +217,67 @@ func SendGroupChatNotice(fromUserId uint64, userIds []uint64, senderExtId string
}
return
nil
}
// 羊羊匹配成功
func
SendSheepMatchSuccess
(
matchId
,
userId1
,
userId2
uint64
,
nick1
,
nick2
,
avatar1
,
avatar2
string
)
error
{
msg
:=
&
userProxy
.
SheepMatchSuccess
{
MatchId
:
matchId
,
UserId1
:
&
userProxy
.
User
{
Id
:
userId1
,
Nick
:
nick1
,
Avatar
:
avatar1
},
UserId2
:
&
userProxy
.
User
{
Id
:
userId2
,
Nick
:
nick2
,
Avatar
:
avatar2
},
}
if
buffer
,
err
:=
proto
.
Marshal
(
msg
);
err
==
nil
{
userIds
:=
[]
uint64
{
userId1
,
userId2
}
rspUids
,
err
:=
multicast
(
userIds
,
MsgTypeSheepGameMatchSuccess
,
buffer
)
//记录socket,注意闭包问题
go
func
(
userIds
[]
uint64
,
msg
*
userProxy
.
SheepMatchSuccess
,
rspUids
[]
uint64
,
err
error
)
{
buf
,
_
:=
json
.
Marshal
(
msg
)
AddRpcLogs
(
MsgTypeSheepGameMatchSuccess
,
userIds
,
string
(
buf
[
:
]),
rspUids
,
err
)
}(
userIds
,
msg
,
rspUids
,
err
)
if
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"grpc SendSheepMatchSuccess send fail"
)
return
err
}
else
{
mylogrus
.
MyLog
.
Info
(
"grpc SendSheepMatchSuccess send success"
)
}
}
else
{
return
err
}
return
nil
}
// 羊羊游戏结果
func
SendSheepGameResult
(
matchId
,
winId
,
userId1
,
userId2
uint64
,
nick1
,
nick2
,
avatar1
,
avatar2
string
)
error
{
var
players
[]
*
userProxy
.
SheepGamePlayer
players
=
append
(
players
,
&
userProxy
.
SheepGamePlayer
{
IsWin
:
winId
==
userId1
,
User
:
&
userProxy
.
User
{
Id
:
userId1
,
Nick
:
nick1
,
Avatar
:
avatar1
,
}})
players
=
append
(
players
,
&
userProxy
.
SheepGamePlayer
{
IsWin
:
winId
==
userId2
,
User
:
&
userProxy
.
User
{
Id
:
userId2
,
Nick
:
nick2
,
Avatar
:
avatar2
,
}})
msg
:=
&
userProxy
.
SheepGameResult
{
MatchId
:
matchId
,
Players
:
players
,
}
if
buffer
,
err
:=
proto
.
Marshal
(
msg
);
err
==
nil
{
userIds
:=
[]
uint64
{
userId1
,
userId2
}
rspUids
,
err
:=
multicast
(
userIds
,
MsgTypeSheepGameResult
,
buffer
)
//记录socket,注意闭包问题
go
func
(
userIds
[]
uint64
,
msg
*
userProxy
.
SheepGameResult
,
rspUids
[]
uint64
,
err
error
)
{
buf
,
_
:=
json
.
Marshal
(
msg
)
AddRpcLogs
(
MsgTypeSheepGameResult
,
userIds
,
string
(
buf
[
:
]),
rspUids
,
err
)
}(
userIds
,
msg
,
rspUids
,
err
)
if
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"grpc SendSheepGameResult send fail"
)
return
err
}
else
{
mylogrus
.
MyLog
.
Info
(
"grpc SendSheepGameResult send success"
)
}
}
else
{
return
err
}
return
nil
}
script/utils/utils_test.go
View file @
2edfa2a3
...
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
}
func
TestJwt
(
t
*
testing
.
T
)
{
token
,
_
:=
jwt
.
GenerateToken
(
45
10
,
"4474ac74c17e42f4820586279eda37c9
"
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
45
49
,
"f98c7fe5698e447c998615332eb660d1
"
,
"hiloApi"
)
t
.
Logf
(
token
)
}
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