game/server/chat/server/processor.go

32 lines
861 B
Go

package server
import (
"game/common/proto/pb"
"game/common/topicName"
"github.com/fox/fox/log"
"github.com/fox/fox/processor"
"github.com/fox/fox/service"
)
func (s *ChatService) initProcessor() {
s.processor.RegisterMessages(processor.RegisterMetas{
pb.MsgId_C2SChatId: {pb.C2SChat{}, s.onChat},
})
}
// 收到登陆成功消息,判断是否顶号
func (s *ChatService) onChat(uid int64, msg *pb.C2SChat) {
switch msg.Type {
case pb.ChatType_CT_Private:
sName, err := s.bindService.FindServiceName(msg.DstUser.UserId, pb.ServiceTypeId_STI_Gate)
if err != nil {
log.DebugF("find user:%v in gate err: %v", uid, err)
return
}
s.SendServiceMsg(service.TopicEx(sName), msg.DstUser.UserId, int32(pb.MsgId_S2CChatId), msg)
default:
s.SendServiceMsg(service.TopicEx(topicName.WorldMessage), uid, int32(pb.MsgId_S2CChatId), msg)
}
}