diff --git a/rpc/user_center_func.go b/rpc/user_center_func.go index 4f9f4264748a3e7571fef94afe1b1b2b2e744cc3..7fff1a2cdf0009be26d2bcd3b4d5359b3a9750c0 100644 --- a/rpc/user_center_func.go +++ b/rpc/user_center_func.go @@ -330,3 +330,32 @@ func SendCpInviteNotice(userId uint64, code, name, avatar, content, extId string } return nil } + +// cp升级 +func SendCpUpgrade(nick1, nick2, avatar1, avatar2 string, cpLevel uint32, content string) error { + msg := &userProxy.CpUpgrade{ + User1: &userProxy.User{Nick: nick1, Avatar: avatar1}, + User2: &userProxy.User{Nick: nick2, Avatar: avatar2}, + CpLevel: cpLevel, + Content: content, + } + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := broadcast(MsgTypeCpUpgrade, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.CpUpgrade, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgTypeCpUpgrade, userId, string(buf[:]), rspUids, err) + }(0, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendCpUpgrade send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendCpUpgrade send success") + } + } else { + return err + } + return nil +}