代码拉取完成,页面将自动刷新
package playerinfo
import (
"context"
"errors"
"net"
"gitee.com/wusuitaitou/cso2014/main_service/client"
"gitee.com/wusuitaitou/cso2014/main_service/constant"
"gitee.com/wusuitaitou/cso2014/main_service/model/out"
"gitee.com/wusuitaitou/cso2014/main_service/model/packet"
"gitee.com/wusuitaitou/cso2014/utils"
)
type UpdateCampaignService interface {
Handle(ctx context.Context) error
}
type updateCampaignServiceImpl struct {
client net.Conn
subtype uint8
campaignID uint8
}
func NewUpdateCampaignService(p *packet.PacketData, client net.Conn) UpdateCampaignService {
return &updateCampaignServiceImpl{
client: client,
subtype: utils.ReadUint8(p.Data, &p.CurOffset),
campaignID: utils.ReadUint8(p.Data, &p.CurOffset),
}
}
func (u *updateCampaignServiceImpl) Handle(ctx context.Context) error {
user := client.GetUserCacheClient().GetUserByConnection(ctx, u.client)
if user == nil || user.UserID == 0 {
return errors.New("can't find user")
}
if u.subtype != 1 {
return errors.New("not update campaign request")
}
switch u.campaignID {
case 1, 2, 4, 8, 16, 32:
info, err := client.GetUserClient().UpdateCampaign(ctx, user.UserID, u.campaignID)
if err != nil {
return err
}
// UserInfo部分
rst := utils.BytesCombine(packet.BuildHeader(user.GetNextSeq(), constant.PacketTypeUserInfo), out.BuildUserInfo(out.NewUserInfo(info), true, 0xFFFFFFFF))
packet.SendPacket(rst, user.CurrentConnection)
return nil
default:
return errors.New("Unknown canpaign id")
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。