36 lines
693 B
Go
36 lines
693 B
Go
package robot
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"log"
|
|
)
|
|
|
|
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
|
switch msg.SubType {
|
|
case "apply":
|
|
r.handleFriendApply(msg)
|
|
}
|
|
}
|
|
|
|
//添加好友
|
|
func (r *Robot) FriendApply(friendId string) {
|
|
req := &pb.FriendApplyReq{
|
|
FriendId: friendId,
|
|
}
|
|
head := &pb.UserMessage{MainType: "friend", SubType: "apply"}
|
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
|
err := r.SendToClient(head, req)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
|
rsp := &pb.FriendApplyRsp{}
|
|
if !comm.ProtoDecode(msg, rsp) {
|
|
return
|
|
}
|
|
printReply(msg, rsp)
|
|
}
|