diff --git a/protocol/userProxy.proto b/protocol/userProxy.proto index 2e616580317d94052911c4dbc15937f77f1eede4..0caaf9d0c8179accf267d0d50084fedb1d9e4f41 100644 --- a/protocol/userProxy.proto +++ b/protocol/userProxy.proto @@ -377,6 +377,10 @@ message SheepMatchSuccess { User user = 2; User otherUser = 3; uint64 game_id = 4; + string channelId = 5; + string token = 6; + uint32 agoraId = 7; + uint32 provider = 8; } message SheepGamePlayer { @@ -473,4 +477,12 @@ message LobbyMatchSuccess { User user = 4; User otherUser = 5; string gameCode = 6; -} \ No newline at end of file +} + +/* id == 158 H5游戏静音 */ +message H5GameVoiceMute { +} + +/* id == 159 H5游戏打开语音 */ +message H5GameVoiceUnMute { +} diff --git a/rpc/user_center_coder.go b/rpc/user_center_coder.go index 91130735195c04c9c7f3c243214c4874fd5c5fcd..4ff9795506307cd18cf06a8bec46569f33a5a992 100644 --- a/rpc/user_center_coder.go +++ b/rpc/user_center_coder.go @@ -68,6 +68,8 @@ const ( MsgTypeSvipUpgrade = 151 // svip升级 MsgTypeGroupMicChange = 155 // 麦位变化 MsgTypeLobbyMatchSuccess = 157 // 羊羊匹配成功 + MsgTypeH5GameMute = 158 // H5游戏静音 + MsgTypeH5GameUnMute = 159 // H5游戏开音 ) const ( diff --git a/rpc/user_center_func.go b/rpc/user_center_func.go index 526ec63c78e7854e47fdb9c7dfc8e2405840dab2..e147053a45f5a242654b7dec203704be7f349470 100644 --- a/rpc/user_center_func.go +++ b/rpc/user_center_func.go @@ -255,6 +255,7 @@ func SendGroupChatNotice(fromUserId uint64, userIds []uint64, senderExtId string } // 羊羊匹配成功 +// Deprecated: missing Params func SendSheepMatchSuccess(matchId, myUserId, otherUserId uint64, nick1, nick2, avatar1, avatar2 string, gameIds ...uint64) error { gameId := uint64(0) if len(gameIds) > 0 { @@ -288,6 +289,40 @@ func SendSheepMatchSuccess(matchId, myUserId, otherUserId uint64, nick1, nick2, return nil } +// 羊羊匹配成功 +func SendSheepMatchSuccessV2(matchId, myUserId, otherUserId uint64, nick1, nick2, avatar1, avatar2 string, gameId uint64, channelId, token string, agoraId uint32, provider int) error { + msg := &userProxy.SheepMatchSuccess{ + MatchId: matchId, + User: &userProxy.User{Id: myUserId, Nick: nick1, Avatar: avatar1}, + OtherUser: &userProxy.User{Id: otherUserId, Nick: nick2, Avatar: avatar2}, + GameId: gameId, + ChannelId: channelId, + Token: token, + AgoraId: agoraId, + Provider: uint32(provider), + } + if buffer, err := proto.Marshal(msg); err == nil { + userIds := []uint64{myUserId} + 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, isAiMap map[uint64]bool, gameIds ...uint64) error { if isAiMap == nil { @@ -508,3 +543,51 @@ func SendLobbyMatchSuccess(myUserId, otherUserId uint64, nick1, nick2, avatar1, } return nil } + +// h5游戏静音 +func SendH5GameMute(userId uint64) error { + msg := &userProxy.H5GameVoiceMute{} + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := multicast([]uint64{userId}, MsgTypeH5GameMute, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.H5GameVoiceMute, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgTypeH5GameUnMute, userId, string(buf[:]), rspUids, err) + }(userId, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendH5GameMute send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendH5GameMute send success") + } + } else { + return err + } + return nil +} + +// h5游戏开音 +func SendH5GameUnMute(userId uint64) error { + msg := &userProxy.H5GameVoiceUnMute{} + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := multicast([]uint64{userId}, MsgTypeH5GameUnMute, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.H5GameVoiceUnMute, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgTypeH5GameUnMute, userId, string(buf[:]), rspUids, err) + }(userId, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendH5GameUnMute send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendH5GameUnMute send success") + } + } else { + return err + } + return nil +}