We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// Kick represents a kick off packet Kick = 0x05 // disconnect message from server
请问这个数据包类型并没有实现吗? 源码没有一个地方调用过该类型。应该需要额外加一个类似s.Response接口来处理Kick类型的数据包吧。
客户端虽然有这个数据包类型的定义接收,但是服务端没有实现这个数据包类型的封装? handlers[Package.TYPE_KICK] = onKick;
The text was updated successfully, but these errors were encountered:
改造如下: 1 session.go文件增加对外暴露方法接口并实现 type NetworkEntity interface { ResponseKick(v interface{}) error }
2.实现 acceptor.go和agent.go 分别实现ResponseKick message.go 增加一个类型 Kick = 0x04
3.回包的时候就指定回packet.Kick类型 func (a *agent) write() { // packet encode var packetType packet.Type if data.typ == message.Kick { packetType = packet.Kick }else { packetType = packet.Data }
p, err := codec.Encode(packetType, em)
}
这样响应客户端就能通过如下解析 handlers[Package.TYPE_KICK] = onKick;
@lonng 这样合理吗, 因为你源码没有一个地方实现了Kick = 0x05 回包类型。
Sorry, something went wrong.
Yes, Prefer
type NetworkEntity interface { Kick(v interface{}) error }
// Kick message to client func (s *Session) Kick(v interface{}) error { return s.entity.Kick(v) }
Kick Type = 0x04
kick, err = codec.Encode(packet.Kick, nil) if err != nil { panic(err) }
func (a *agent) Kick(v interface{}) error { if a.status() == statusClosed { return ErrBrokenPipe } return a.send(pendingMessage{typ: message.Kick}) } func(a * agent)write(){ ...省略 if data.typ == message.Kick { chWrite <- kick break } ...省略 }
No branches or pull requests
Question @lonng
// Kick represents a kick off packet
Kick = 0x05 // disconnect message from server
请问这个数据包类型并没有实现吗?
源码没有一个地方调用过该类型。应该需要额外加一个类似s.Response接口来处理Kick类型的数据包吧。
客户端虽然有这个数据包类型的定义接收,但是服务端没有实现这个数据包类型的封装?
handlers[Package.TYPE_KICK] = onKick;
The text was updated successfully, but these errors were encountered: