From ff0bebfe32c4acc2cfd14282ee05520f5de11e9e Mon Sep 17 00:00:00 2001 From: iamhujiebin <458249864@qq.com> Date: Tue, 8 Aug 2023 23:40:47 +0800 Subject: [PATCH] SendFruitMachineToUser --- rpc/user_center_func.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rpc/user_center_func.go b/rpc/user_center_func.go index cc8f596..526ec63 100644 --- a/rpc/user_center_func.go +++ b/rpc/user_center_func.go @@ -35,6 +35,32 @@ func SendFruitMachine(date string, round uint32) error { return nil } +func SendFruitMachineToUser(date string, round uint32, userIds []uint64) error { + msg := &userProxy.FruitMachine{ + Date: date, + Round: round, + } + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := multicast(userIds, MsgFruitMachine, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.FruitMachine, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgFruitMachine, userId, string(buf[:]), rspUids, err) + }(0, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendFruitMachine send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendFruitMachine send success") + } + } else { + return err + } + return nil +} + func SendGlobalRocketNotice(groupId string, period string, round uint32, stage uint32, fromUserId uint64, topUserIcon string, nick string, code string, avatar string) error { msg := &userProxy.GlobalRocketNotice{ GroupId: groupId, -- 2.22.0