From 88fb33028512db60a3c9cc55b377c94f793944bd Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Tue, 15 Aug 2023 15:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=88=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/userProxy.proto | 4 ++++ rpc/user_center_func.go | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/protocol/userProxy.proto b/protocol/userProxy.proto index f2ec9ea..1bea214 100644 --- a/protocol/userProxy.proto +++ b/protocol/userProxy.proto @@ -487,3 +487,7 @@ message H5GameVoiceMute { /* id == 159 H5游戏打开语音 */ message H5GameVoiceUnMute { } + +/* id == 160 退出房间 */ +message QuitRoom { +} diff --git a/rpc/user_center_func.go b/rpc/user_center_func.go index 419c6e7..82886ce 100644 --- a/rpc/user_center_func.go +++ b/rpc/user_center_func.go @@ -592,3 +592,29 @@ func SendH5GameUnMute(userId uint64) error { } return nil } + +// 发送退房通知 +func SendQuitRoom(userId uint64) error { + msg := &userProxy.DiamondChange{} + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := multicast([]uint64{userId}, MsgTypeQuitRoom, buffer) + // 记录socket + // 有err||uid不在线才入库 + if err != nil || len(rspUids) > 0 { + go func(userId uint64, msg *userProxy.DiamondChange, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgTypeQuitRoom, userId, string(buf[:]), rspUids, err) + }(userId, msg, rspUids, err) + } + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendQuitRoom send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendQuitRoom send success") + } + } else { + return err + } + return nil +} -- 2.22.0