Commit 2edfa2a3 authored by hujiebin's avatar hujiebin

羊羊两个ws

parent ac71646a
...@@ -365,3 +365,21 @@ message GlobalGameBanner { ...@@ -365,3 +365,21 @@ message GlobalGameBanner {
string bannerUrl = 5; string bannerUrl = 5;
uint64 gameId = 6; // 1.ludo 2.uno 3.dice 4.lucky wheel 5.lucky box 6.fruit 7.slot 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
...@@ -61,6 +61,8 @@ const ( ...@@ -61,6 +61,8 @@ const (
MsgRoomInviteMember = 144 // 邀请用户成为房间会员 MsgRoomInviteMember = 144 // 邀请用户成为房间会员
MsgDiamondChange = 145 // 钻石数变化 MsgDiamondChange = 145 // 钻石数变化
MsgTypeGlobalGameBanner = 146 // 游戏横幅 MsgTypeGlobalGameBanner = 146 // 游戏横幅
MsgTypeSheepGameMatchSuccess = 147 // 羊羊匹配成功
MsgTypeSheepGameResult = 148 // 羊羊游戏结果
) )
const ( const (
......
...@@ -217,3 +217,67 @@ func SendGroupChatNotice(fromUserId uint64, userIds []uint64, senderExtId string ...@@ -217,3 +217,67 @@ func SendGroupChatNotice(fromUserId uint64, userIds []uint64, senderExtId string
} }
return nil 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
}
...@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) { ...@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
} }
func TestJwt(t *testing.T) { func TestJwt(t *testing.T) {
token, _ := jwt.GenerateToken(4510, "4474ac74c17e42f4820586279eda37c9", "hiloApi") token, _ := jwt.GenerateToken(4549, "f98c7fe5698e447c998615332eb660d1", "hiloApi")
t.Logf(token) t.Logf(token)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment