1 Star 0 Fork 0

Ms.Guo/CSO2014

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
playerinfo.go 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
libaojie 提交于 2024-10-31 17:38 . 初始化
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")
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wusuitaitou/cso2014.git
git@gitee.com:wusuitaitou/cso2014.git
wusuitaitou
cso2014
CSO2014
v1.0.0

搜索帮助

0d507c66 1850385 C8b1a773 1850385