1 Star 0 Fork 0

Ms.Guo/CSO2014

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
option.go 857 Bytes
一键复制 编辑 原始数据 按行查看 历史
libaojie 提交于 2024-10-31 17:38 +08:00 . 初始化
package option
import (
"context"
"errors"
"net"
"gitee.com/wusuitaitou/cso2014/main_service/client"
"gitee.com/wusuitaitou/cso2014/main_service/model/packet"
"gitee.com/wusuitaitou/cso2014/utils"
)
type OptionService interface {
Handle(ctx context.Context) error
}
type optionServiceImpl struct {
data []byte
client net.Conn
}
func NewOptionService(p *packet.PacketData, client net.Conn) OptionService {
len := utils.ReadUint16(p.Data, &p.CurOffset)
return &optionServiceImpl{
data: utils.ReadString(p.Data, &p.CurOffset, int(len)),
client: client,
}
}
func (s *optionServiceImpl) Handle(ctx context.Context) error {
u := client.GetUserCacheClient().GetUserByConnection(ctx, s.client)
if u == nil {
return errors.New("can't find user")
}
_, err := client.GetUserClient().UpdateOptions(ctx, u.UserID, s.data)
return err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wusuitaitou/cso2014.git
git@gitee.com:wusuitaitou/cso2014.git
wusuitaitou
cso2014
CSO2014
v1.0.0

搜索帮助