doc[module]: 网关授权 和 心跳时间 注释

This commit is contained in:
jianan
2022-07-11 14:50:14 +08:00
parent 74212d1b5e
commit 5d725515de
2 changed files with 5 additions and 0 deletions
@@ -42,6 +42,8 @@ public class TcpClient extends AbstractClient {
private static class ChannelHandlerInitializer extends ChannelInitializer<SocketChannel> {
@Override
protected void initChannel(SocketChannel channel) {
// 可以看出来,这个客户端检测到空闲的时间是60s,相对短一点,这样子就可以发送心跳。
// 服务器端则是180s,相对长一点,一旦检测到空闲,则把客户端踢掉。
channel.pipeline().addLast(new IdleStateHandler(0, 0, 60));
channel.pipeline().addLast(new ClientIdleHandler());
channel.pipeline().addLast(new TcpCodecHandler());
@@ -114,13 +114,16 @@ public class Router implements IRouter {
if (gatewayAttachment.isClient()) {
gatewayAttachment.setClient(false);
} else {
// 这里是:别的服务提供者提供授权给网关,比如:在玩家登录后,home服查到了玩家uid,然后发给Gateway服
var gatewaySession = NetContext.getSessionManager().getServerSession(gatewayAttachment.getSid());
if (gatewaySession != null) {
var signalAttachmentInGatewayAttachment = gatewayAttachment.getSignalAttachment();
if (signalAttachmentInGatewayAttachment != null) {
signalAttachmentInGatewayAttachment.setClient(false);
}
// 网关授权,授权完成直接返回
// 注意:这个 AuthUidToGatewayCheck 是在home的LoginController中处理完登录后,把消息发给网关进行授权
if (AuthUidToGatewayCheck.getAuthProtocolId() == packet.protocolId()) {
var uid = ((AuthUidToGatewayCheck) packet).getUid();
if (uid <= 0) {