Переглянути джерело

暂时屏蔽请求过滤器

johnclot69 2 місяців тому
батько
коміт
7fed5f180a

+ 12 - 7
incubator-game/src/main/java/com/incubator/game/listener/PublicListener.java

@@ -31,9 +31,14 @@ public class PublicListener extends GameServerConnectionListener {
 	@Override
 	public void connectionClosed(Connection connection) {
 		try {
-			GPlayer player = GGame.onlinePlayers.get(connection.getPlayerId());
-			if (player != null && player.getSession().getHashCode() == connection.hashCode()) {
-				((Player) player).destroy();
+			if (connection != null && connection.getPlayerId() != null) {
+				GPlayer player = GGame.onlinePlayers.get(connection.getPlayerId());
+				if (player != null && player.getSession().getHashCode() == connection.hashCode()) {
+					// 执行玩家登出操作
+					((Player) player).destroy();
+				}
+			} else {
+				Log.warn("无法处理玩家退出,PlayerId为空,connection={}", connection);
 			}
 		} catch (Exception e) {
 			Log.error("玩家退出时发生异常: ", e);
@@ -69,10 +74,10 @@ public class PublicListener extends GameServerConnectionListener {
 
 			// 从对象池获取 WSRequest 实例
 			request = WSRequestPool.getRequest(bytes);
-			if (!RequestFilter.isAllowed(conn, request.getCmd())) {
-				Log.warn("请求过于频繁,已被过滤: cmd={}, player={}", request.getCmd(), conn.getPlayerId());
-				return;
-			}
+//			if (!RequestFilter.isAllowed(conn, request.getCmd())) {
+//				Log.warn("请求过于频繁,已被过滤: cmd={}, player={}", request.getCmd(), conn.getPlayerId());
+//				return;
+//			}
 
 			// 获取处理器
 			NetHandler handler = GGame.handlers.get(request.getCmd());