mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-24 19:35:29 +00:00
ref[net]: refactored the session event
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
package com.zfoo.boot;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.config.manager.ConfigManager;
|
||||
import com.zfoo.net.config.ConfigManager;
|
||||
import com.zfoo.net.config.model.NetConfig;
|
||||
import com.zfoo.net.consumer.Consumer;
|
||||
import com.zfoo.net.packet.service.PacketService;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.zfoo.net;
|
||||
|
||||
import com.zfoo.net.config.manager.IConfigManager;
|
||||
import com.zfoo.net.config.IConfigManager;
|
||||
import com.zfoo.net.consumer.IConsumer;
|
||||
import com.zfoo.net.core.AbstractClient;
|
||||
import com.zfoo.net.core.AbstractServer;
|
||||
|
||||
+1
-3
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,7 +10,7 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.net.config.manager;
|
||||
package com.zfoo.net.config;
|
||||
|
||||
import com.zfoo.net.config.model.NetConfig;
|
||||
import com.zfoo.net.consumer.registry.IRegistry;
|
||||
@@ -20,7 +19,6 @@ import com.zfoo.protocol.ProtocolManager;
|
||||
import com.zfoo.protocol.collection.CollectionUtils;
|
||||
import com.zfoo.protocol.util.AssertionUtils;
|
||||
import com.zfoo.protocol.util.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
+1
-5
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,13 +10,10 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.net.config.manager;
|
||||
package com.zfoo.net.config;
|
||||
|
||||
import com.zfoo.net.config.model.NetConfig;
|
||||
import com.zfoo.net.consumer.balancer.AbstractConsumerLoadBalancer;
|
||||
import com.zfoo.net.consumer.balancer.IConsumerLoadBalancer;
|
||||
import com.zfoo.net.consumer.registry.IRegistry;
|
||||
import com.zfoo.protocol.registration.ProtocolModule;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,7 +10,7 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.net.core.tcp.model;
|
||||
package com.zfoo.net.core.event;
|
||||
|
||||
import com.zfoo.event.model.event.IEvent;
|
||||
import com.zfoo.net.session.Session;
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,7 +10,7 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.net.core.tcp.model;
|
||||
package com.zfoo.net.core.event;
|
||||
|
||||
import com.zfoo.event.model.event.IEvent;
|
||||
import com.zfoo.net.router.attachment.IAttachment;
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
@@ -11,7 +10,7 @@
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.net.core.tcp.model;
|
||||
package com.zfoo.net.core.event;
|
||||
|
||||
import com.zfoo.event.model.event.IEvent;
|
||||
import com.zfoo.net.session.Session;
|
||||
@@ -15,7 +15,7 @@ package com.zfoo.net.handler;
|
||||
|
||||
import com.zfoo.event.manager.EventBus;
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.core.tcp.model.ClientSessionInactiveEvent;
|
||||
import com.zfoo.net.core.event.ClientSessionInactiveEvent;
|
||||
import com.zfoo.net.util.SessionUtils;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class GatewayRouteHandler extends ServerRouteHandler {
|
||||
} else {
|
||||
// 使用用户的uid做一致性hash
|
||||
var uid = session.getUid();
|
||||
if (uid < 0) {
|
||||
if (uid <= 0) {
|
||||
forwardingPacket(packet, gatewayAttachment, uid);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ package com.zfoo.net.handler;
|
||||
|
||||
import com.zfoo.event.manager.EventBus;
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.core.tcp.model.ServerSessionInactiveEvent;
|
||||
import com.zfoo.net.core.event.ServerSessionInactiveEvent;
|
||||
import com.zfoo.net.util.SessionUtils;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
@@ -15,10 +15,10 @@ package com.zfoo.net.router;
|
||||
|
||||
import com.zfoo.event.manager.EventBus;
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.core.event.ServerExceptionEvent;
|
||||
import com.zfoo.net.core.gateway.model.AuthUidToGatewayCheck;
|
||||
import com.zfoo.net.core.gateway.model.AuthUidToGatewayConfirm;
|
||||
import com.zfoo.net.core.gateway.model.AuthUidToGatewayEvent;
|
||||
import com.zfoo.net.core.tcp.model.ServerExceptionEvent;
|
||||
import com.zfoo.net.packet.common.Error;
|
||||
import com.zfoo.net.packet.common.Heartbeat;
|
||||
import com.zfoo.net.packet.model.EncodedPacketInfo;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package com.zfoo.net.schema;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.config.manager.ConfigManager;
|
||||
import com.zfoo.net.config.ConfigManager;
|
||||
import com.zfoo.net.config.model.*;
|
||||
import com.zfoo.net.consumer.Consumer;
|
||||
import com.zfoo.net.packet.service.PacketService;
|
||||
|
||||
@@ -33,10 +33,10 @@ public class Session implements Closeable {
|
||||
private long sid;
|
||||
|
||||
/**
|
||||
* EN:The default user ID is an ID greater than 0, or less than 0 if there is no login
|
||||
* CN:默认用户的id都是大于0的id,如果没有登录则小于0
|
||||
* EN:The default user ID is an ID greater than 0, or equal 0 if there is no login
|
||||
* CN:默认用户的id都是大于0的id,如果没有登录则等于0
|
||||
*/
|
||||
private long uid = -1;
|
||||
private long uid = 0;
|
||||
|
||||
private Channel channel;
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class TaskBus {
|
||||
if (attachment == null) {
|
||||
var session = task.getSession();
|
||||
var uid = session.getUid();
|
||||
if (uid < 0) {
|
||||
if (uid <= 0) {
|
||||
execute((int) session.getSid(), task);
|
||||
} else {
|
||||
execute(uid, task);
|
||||
|
||||
@@ -73,7 +73,7 @@ org.springframework.context.event.internalEventListenerProcessor
|
||||
org.springframework.context.event.internalEventListenerFactory
|
||||
com.zfoo.net.config.model.NetConfig
|
||||
com.zfoo.net.NetContext
|
||||
com.zfoo.net.config.manager.ConfigManager
|
||||
com.zfoo.net.config.ConfigManager
|
||||
com.zfoo.net.packet.service.PacketService
|
||||
com.zfoo.net.router.Router
|
||||
com.zfoo.net.consumer.Consumer
|
||||
|
||||
Reference in New Issue
Block a user