Files
bl/logic/controller/user_friend.go
xinian 6510e4e09b
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构入参类型引用
2026-04-05 07:24:36 +08:00

69 lines
2.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/friend"
"blazing/logic/service/player"
)
// GetOnlineFriends 获取在线好友列表
// data: 包含用户ID列表的输入信息
// c: 当前玩家对象
// 返回: 好友在线信息和错误码
func (h Controller) GetOnlineFriends(data *SeeOnlineInboundInfo, c *player.Player) (result *friend.SeeOnlineOutboundInfo, err errorcode.ErrorCode) {
result = &friend.SeeOnlineOutboundInfo{}
result.Friends = make([]friend.OnlineInfo, 0)
return
}
// FriendAdd 处理添加好友请求
// data: 包含要添加好友的用户ID
// c: 当前玩家对象
// 返回: 无数据内容的响应和错误码
func (h Controller) FriendAdd(data *FriendAddInboundInfo, c *player.Player) (result fight.NullOutboundInfo, err errorcode.ErrorCode) {
v, ok := c.GetSpace().User.Load(data.UserID)
if ok {
v.SendPackCmd(8001, friend.InformMessage{
UserID: c.Info.UserID,
Nick: c.Info.Nick,
Type: data.Head.CMD,
})
}
return
}
// FriendAnswer 处理好友请求的回复
// data: 包含发起好友请求的用户ID和回复标志(1为同意0为拒绝)
// c: 当前玩家对象
// 返回: 无数据内容的响应和错误码
func (h Controller) FriendAnswer(data *FriendAnswerInboundInfo, c *player.Player) (result fight.NullOutboundInfo, err errorcode.ErrorCode) {
v, ok := c.GetSpace().User.Load(data.UserID)
if ok {
v.SendPackCmd(8001, friend.InformMessage{
UserID: c.Info.UserID,
Nick: c.Info.Nick,
Type: data.Head.CMD,
Accept: data.Flag,
})
v.(*player.Player).Service.Friend.Add(c.Info.UserID)
c.Service.Friend.Add(data.UserID)
}
return
}
// FriendRemove 删除好友
// data: 包含要删除的好友ID
// c: 当前玩家对象
// 返回: 无数据内容的响应和错误码
func (h Controller) FriendRemove(data *FriendRemoveInboundInfo, c *player.Player) (result fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.Service.Friend.Del(data.UserID)
return
}