From 7b60f59f1ce29609e590aa4c6a30388147f930b1 Mon Sep 17 00:00:00 2001 From: noear Date: Wed, 23 Oct 2024 20:39:32 +0800 Subject: [PATCH] 3.0.2 --- .../stomp/handle/ForwardStompListener.java | 4 +- .../stomp/listener/SimpleStompListener.java | 50 ------------------- .../net/stomp/listener/StompListener.java | 16 ++++-- .../java/demo/server/ChatStompBroker.java | 4 +- 4 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/SimpleStompListener.java diff --git a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/handle/ForwardStompListener.java b/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/handle/ForwardStompListener.java index 9897b91b8f..d2d1066446 100644 --- a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/handle/ForwardStompListener.java +++ b/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/handle/ForwardStompListener.java @@ -21,7 +21,7 @@ import org.noear.solon.core.handle.Handler; import org.noear.solon.net.stomp.*; import org.noear.solon.net.stomp.broker.impl.StompBrokerMedia; -import org.noear.solon.net.stomp.listener.SimpleStompListener; +import org.noear.solon.net.stomp.listener.StompListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +32,7 @@ * @author noear * @since 3.0 */ -public class ForwardStompListener implements SimpleStompListener { +public class ForwardStompListener implements StompListener { static final Logger log = LoggerFactory.getLogger(ForwardStompListener.class); private final StompBrokerMedia brokerMedia; diff --git a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/SimpleStompListener.java b/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/SimpleStompListener.java deleted file mode 100644 index d90f28e175..0000000000 --- a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/SimpleStompListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2017-2024 noear.org and 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 - * - * https://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 org.noear.solon.net.stomp.listener; - -import org.noear.solon.net.stomp.Frame; -import org.noear.solon.net.stomp.StompSession; - -/** - * 简单消息监听器 - * - * @author noear - * @since 2.7 - * @since 3.0 - */ -public interface SimpleStompListener extends StompListener { - - - @Override - default void onOpen(StompSession session) { - - } - - @Override - default void onFrame(StompSession session, Frame frame) throws Throwable { - - } - - @Override - default void onClose(StompSession session) { - - } - - @Override - default void onError(StompSession session, Throwable error) { - - } -} diff --git a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/StompListener.java b/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/StompListener.java index 6fc8e3e274..c297470dd6 100644 --- a/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/StompListener.java +++ b/solon-projects/solon-net/solon-net-stomp/src/main/java/org/noear/solon/net/stomp/listener/StompListener.java @@ -32,7 +32,9 @@ public interface StompListener { * * @param session */ - void onOpen(StompSession session); + default void onOpen(StompSession session) { + + } /** * 收到消息帧 @@ -40,19 +42,25 @@ public interface StompListener { * @param session * @param frame 帧 */ - void onFrame(StompSession session, Frame frame) throws Throwable; + default void onFrame(StompSession session, Frame frame) throws Throwable { + + } /** * 连接关闭时(被动监听;当断开时触发) * * @param session */ - void onClose(StompSession session); + default void onClose(StompSession session) { + + } /** * 出错时 * * @param session */ - void onError(StompSession session, Throwable error); + default void onError(StompSession session, Throwable error) { + + } } diff --git a/solon-projects/solon-net/solon-net-stomp/src/test/java/demo/server/ChatStompBroker.java b/solon-projects/solon-net/solon-net-stomp/src/test/java/demo/server/ChatStompBroker.java index 0bb0e1f581..28e1acf93e 100644 --- a/solon-projects/solon-net/solon-net-stomp/src/test/java/demo/server/ChatStompBroker.java +++ b/solon-projects/solon-net/solon-net-stomp/src/test/java/demo/server/ChatStompBroker.java @@ -20,7 +20,7 @@ import org.noear.solon.net.stomp.Message; import org.noear.solon.net.stomp.StompSession; import org.noear.solon.net.stomp.broker.StompBroker; -import org.noear.solon.net.stomp.listener.SimpleStompListener; +import org.noear.solon.net.stomp.listener.StompListener; /** * stomp server 必须 @@ -29,7 +29,7 @@ * @since 2.4 */ @ServerEndpoint("/chat") -public class ChatStompBroker extends StompBroker implements SimpleStompListener { +public class ChatStompBroker extends StompBroker implements StompListener { public ChatStompBroker() { //此为示例,实际按需扩展 this.addListener(this);