diff --git a/boot/src/main/java/com/zfoo/boot/graalvm/GraalvmNetHints.java b/boot/src/main/java/com/zfoo/boot/graalvm/GraalvmNetHints.java index 91d1ec52..f7aca9e5 100644 --- a/boot/src/main/java/com/zfoo/boot/graalvm/GraalvmNetHints.java +++ b/boot/src/main/java/com/zfoo/boot/graalvm/GraalvmNetHints.java @@ -56,9 +56,6 @@ public class GraalvmNetHints implements RuntimeHintsRegistrar { classes.add(UdpAttachment.class); classes.add(HttpAttachment.class); classes.add(NoAnswerAttachment.class); - classes.add(AuthUidToGatewayCheck.class); - classes.add(AuthUidToGatewayConfirm.class); - classes.add(AuthUidAsk.class); classes.add(GatewaySessionInactiveAsk.class); classes.add(GatewaySynchronizeSidAsk.class); diff --git a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidAsk.java b/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidAsk.java deleted file mode 100644 index c99a5bb8..00000000 --- a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidAsk.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.net.core.gateway.model; - -import com.zfoo.protocol.anno.Protocol; - -/** - * @author godotg - */ -@Protocol(id = 22) -public class AuthUidAsk { - - private String gatewayHostAndPort; - - private long sid; - private long uid; - - public static AuthUidAsk valueOf(String gatewayHostAndPort, long sid, long uid) { - var ask = new AuthUidAsk(); - ask.gatewayHostAndPort = gatewayHostAndPort; - ask.sid = sid; - ask.uid = uid; - return ask; - } - - public String getGatewayHostAndPort() { - return gatewayHostAndPort; - } - - public void setGatewayHostAndPort(String gatewayHostAndPort) { - this.gatewayHostAndPort = gatewayHostAndPort; - } - - public long getSid() { - return sid; - } - - public void setSid(long sid) { - this.sid = sid; - } - - public long getUid() { - return uid; - } - - public void setUid(long uid) { - this.uid = uid; - } -} diff --git a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayCheck.java b/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayCheck.java deleted file mode 100644 index e96574fd..00000000 --- a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayCheck.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.net.core.gateway.model; - -import com.zfoo.protocol.anno.Protocol; - -/** - * 网关登录成功过后,将uid授权给网关 - * - * @author godotg - */ -@Protocol(id = 20) -public class AuthUidToGatewayCheck { - - private long uid; - - public static AuthUidToGatewayCheck valueOf(long uid) { - var authUidToGateway = new AuthUidToGatewayCheck(); - authUidToGateway.uid = uid; - return authUidToGateway; - } - - public long getUid() { - return uid; - } - - public void setUid(long uid) { - this.uid = uid; - } -} diff --git a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayConfirm.java b/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayConfirm.java deleted file mode 100644 index 7de2c056..00000000 --- a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayConfirm.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.net.core.gateway.model; - -import com.zfoo.protocol.anno.Protocol; - -/** - * 网关登录成功过后,将uid授权给网关的返回 - * - * @author godotg - */ -@Protocol(id = 21) -public class AuthUidToGatewayConfirm { - - private long uid; - - public static AuthUidToGatewayConfirm valueOf(long uid) { - var authUidToGateway = new AuthUidToGatewayConfirm(); - authUidToGateway.uid = uid; - return authUidToGateway; - } - - public long getUid() { - return uid; - } - - public void setUid(long uid) { - this.uid = uid; - } -} diff --git a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayEvent.java b/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayEvent.java deleted file mode 100644 index c2e8f7ac..00000000 --- a/net/src/main/java/com/zfoo/net/core/gateway/model/AuthUidToGatewayEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.net.core.gateway.model; - -import com.zfoo.event.model.IEvent; - -/** - * @author godotg - */ -public class AuthUidToGatewayEvent implements IEvent { - - private long sid; - private long uid; - - public static AuthUidToGatewayEvent valueOf(long sid, long uid) { - var event = new AuthUidToGatewayEvent(); - event.sid = sid; - event.uid = uid; - return event; - } - - public long getSid() { - return sid; - } - - public void setSid(long sid) { - this.sid = sid; - } - - public long getUid() { - return uid; - } - - public void setUid(long uid) { - this.uid = uid; - } -} diff --git a/net/src/main/java/com/zfoo/net/router/Router.java b/net/src/main/java/com/zfoo/net/router/Router.java index f3559a69..40e70f95 100644 --- a/net/src/main/java/com/zfoo/net/router/Router.java +++ b/net/src/main/java/com/zfoo/net/router/Router.java @@ -18,9 +18,6 @@ import com.zfoo.net.NetContext; import com.zfoo.net.anno.PacketReceiver; import com.zfoo.net.anno.Task; 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.packet.EncodedPacketInfo; import com.zfoo.net.packet.PacketService; import com.zfoo.net.packet.common.Error; @@ -135,21 +132,6 @@ public class Router implements IRouter { logger.warn("gateway receives packet:[{}] and attachment:[{}] from server" + ", but serverSessionMap has no session[id:{}], perhaps client disconnected from gateway.", JsonUtils.object2String(packet), JsonUtils.object2String(attachment), gatewayAttachment.getSid()); return; } - - // 网关授权,授权完成直接返回 - // 注意:这个 AuthUidToGatewayCheck 是在home的LoginController中处理完登录后,把消息发给网关进行授权 - if (AuthUidToGatewayCheck.class == packet.getClass()) { - var uid = ((AuthUidToGatewayCheck) packet).getUid(); - if (uid <= 0) { - logger.error("错误的网关授权信息,uid必须大于0"); - return; - } - gatewaySession.setUid(uid); - EventBus.post(AuthUidToGatewayEvent.valueOf(gatewaySession.getSid(), uid)); - - NetContext.getRouter().send(session, AuthUidToGatewayConfirm.valueOf(uid), new GatewayAttachment(gatewaySession)); - return; - } send(gatewaySession, packet, gatewayAttachment.getSignalAttachment()); } return; diff --git a/net/src/test/resources/protocol.xml b/net/src/test/resources/protocol.xml index b82dae7f..5ed8bf9a 100644 --- a/net/src/test/resources/protocol.xml +++ b/net/src/test/resources/protocol.xml @@ -11,9 +11,6 @@ - - -