添加client测试端
This commit is contained in:
parent
7b18e9a8b6
commit
3752feb4ef
@ -158,7 +158,8 @@ func (s *GateService) OnMessage(data []byte) error {
|
||||
*/
|
||||
func (s *GateService) findTopic(userId int64, serviceTypeId pb.ServiceTypeId) (topic, sName string) {
|
||||
if userId != 0 {
|
||||
if sName, err := s.bindService.FindServiceName(userId, serviceTypeId); err == nil {
|
||||
var err error
|
||||
if sName, err = s.bindService.FindServiceName(userId, serviceTypeId); err == nil {
|
||||
return service.TopicEx(sName), sName
|
||||
} else {
|
||||
log.Error(err.Error())
|
||||
@ -181,6 +182,12 @@ func (s *GateService) WsOnMessage(conn ws.IConn, data []byte) {
|
||||
topic, msg.ServiceName = s.findTopic(conn.UserId(), msg.ServiceTid)
|
||||
}
|
||||
if topic != "" {
|
||||
if msg.MsgId == int32(pb.MsgId_C2SUserLoginId) {
|
||||
req := &pb.C2SUserLogin{}
|
||||
_ = proto.Unmarshal(msg.Data, req)
|
||||
req.Ip = conn.Addr()
|
||||
msg.Data, _ = proto.Marshal(req)
|
||||
}
|
||||
s.SendServiceData(topic, conn, msg.MsgId, msg.Data)
|
||||
} else {
|
||||
log.Error(s.Log("topic:%v not exist.user:%v", topic, conn.UserId()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user