feat(对操作类增加错误参数): 对操作类增加错误参数
* 添加操作Operation类的Error方法错误的参数,同时移除无参方法 BREAKING CHANGE: 移除了Operation错误方法的无参实现
This commit is contained in:
parent
5c4dd0dcdd
commit
de25eb9011
|
|
@ -297,7 +297,7 @@ public abstract class AbstractWebSocketClient {
|
||||||
ClientChannel = channelFuture.sync().channel();
|
ClientChannel = channelFuture.sync().channel();
|
||||||
ClientChannel.closeFuture().sync();
|
ClientChannel.closeFuture().sync();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
startingError();
|
startingError("Catch Exception: " + e.getMessage());
|
||||||
ClientStatus = Status.ERROR;
|
ClientStatus = Status.ERROR;
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -320,15 +320,15 @@ public abstract class AbstractWebSocketClient {
|
||||||
starting();
|
starting();
|
||||||
switch (ClientStatus) {
|
switch (ClientStatus) {
|
||||||
case STARTING -> {
|
case STARTING -> {
|
||||||
startingError();
|
startingError("Client is already starting");
|
||||||
logger.info("Client is already starting.");
|
logger.info("Client is already starting.");
|
||||||
}
|
}
|
||||||
case RUNNING -> {
|
case RUNNING -> {
|
||||||
startingError();
|
startingError("Client is already running.");
|
||||||
logger.info("Client is already running.");
|
logger.info("Client is already running.");
|
||||||
}
|
}
|
||||||
case STOPPING -> {
|
case STOPPING -> {
|
||||||
startingError();
|
startingError("Client is stopping");
|
||||||
logger.info("Client is stopping");
|
logger.info("Client is stopping");
|
||||||
}
|
}
|
||||||
case STOPPED, WAITING_FOR_INIT -> {
|
case STOPPED, WAITING_FOR_INIT -> {
|
||||||
|
|
@ -356,7 +356,7 @@ public abstract class AbstractWebSocketClient {
|
||||||
/**
|
/**
|
||||||
* Starting error.
|
* Starting error.
|
||||||
*/
|
*/
|
||||||
protected abstract void startingError();
|
protected abstract void startingError(String msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Started.
|
* Started.
|
||||||
|
|
@ -371,7 +371,7 @@ public abstract class AbstractWebSocketClient {
|
||||||
/**
|
/**
|
||||||
* Stopping error.
|
* Stopping error.
|
||||||
*/
|
*/
|
||||||
protected abstract void stoppingError();
|
protected abstract void stoppingError(String msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stopped.
|
* Stopped.
|
||||||
|
|
@ -385,11 +385,11 @@ public abstract class AbstractWebSocketClient {
|
||||||
stopping();
|
stopping();
|
||||||
switch (ClientStatus) {
|
switch (ClientStatus) {
|
||||||
case WAITING_FOR_INIT -> {
|
case WAITING_FOR_INIT -> {
|
||||||
stoppingError();
|
stoppingError("Client is not initialized.");
|
||||||
logger.warn("Not Init. (It shouldn't be happened)");
|
logger.warn("Not Init. (It shouldn't be happened)");
|
||||||
}
|
}
|
||||||
case STARTING -> {
|
case STARTING -> {
|
||||||
stoppingError();
|
stoppingError("Client is already starting.");
|
||||||
logger.info("Client is starting, please waiting.");
|
logger.info("Client is starting, please waiting.");
|
||||||
}
|
}
|
||||||
case RUNNING, ERROR -> {
|
case RUNNING, ERROR -> {
|
||||||
|
|
@ -424,11 +424,11 @@ public abstract class AbstractWebSocketClient {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case STOPPING -> {
|
case STOPPING -> {
|
||||||
stoppingError();
|
stoppingError("Client is already stopping.");
|
||||||
logger.info("Client is already stopping");
|
logger.info("Client is already stopping");
|
||||||
}
|
}
|
||||||
case STOPPED -> {
|
case STOPPED -> {
|
||||||
stoppingError();
|
stoppingError("Client has been stopped.");
|
||||||
logger.info("Client has stopped");
|
logger.info("Client has stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package com.r3944realms.dg_lab.websocket;
|
package com.r3944realms.dg_lab.websocket;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Since;
|
||||||
import com.r3944realms.dg_lab.DgLab;
|
import com.r3944realms.dg_lab.DgLab;
|
||||||
import com.r3944realms.dg_lab.api.manager.Status;
|
import com.r3944realms.dg_lab.api.manager.Status;
|
||||||
import com.r3944realms.dg_lab.utils.stringUtils.UrlValidator;
|
import com.r3944realms.dg_lab.utils.stringUtils.UrlValidator;
|
||||||
|
|
@ -248,7 +249,7 @@ public abstract class AbstractWebSocketServer {
|
||||||
channelFuture.channel().closeFuture().sync();
|
channelFuture.channel().closeFuture().sync();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ServerStatus = Status.ERROR;
|
ServerStatus = Status.ERROR;
|
||||||
stoppingError();
|
stoppingError("Catch Exception:" + e.getMessage());
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if(ServerStatus == Status.ERROR || ServerStatus == Status.RUNNING) stop();
|
if(ServerStatus == Status.ERROR || ServerStatus == Status.RUNNING) stop();
|
||||||
|
|
@ -262,10 +263,12 @@ public abstract class AbstractWebSocketServer {
|
||||||
*/
|
*/
|
||||||
protected abstract void starting();
|
protected abstract void starting();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting error.
|
* Starting error(With error result).
|
||||||
*/
|
*/
|
||||||
protected abstract void startingError();
|
protected abstract void startingError(String error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Started.
|
* Started.
|
||||||
|
|
@ -280,8 +283,7 @@ public abstract class AbstractWebSocketServer {
|
||||||
/**
|
/**
|
||||||
* Stopping error.
|
* Stopping error.
|
||||||
*/
|
*/
|
||||||
protected abstract void stoppingError();
|
protected abstract void stoppingError(String error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stopped.
|
* Stopped.
|
||||||
*/
|
*/
|
||||||
|
|
@ -301,15 +303,15 @@ public abstract class AbstractWebSocketServer {
|
||||||
starting();
|
starting();
|
||||||
switch (ServerStatus) {
|
switch (ServerStatus) {
|
||||||
case STARTING -> {
|
case STARTING -> {
|
||||||
startingError();
|
startingError("Server is already starting.");
|
||||||
logger.info("Server is already starting.");
|
logger.info("Server is already starting.");
|
||||||
}
|
}
|
||||||
case RUNNING -> {
|
case RUNNING -> {
|
||||||
startingError();
|
startingError("Server is already running.");
|
||||||
logger.info("Server is already running.");
|
logger.info("Server is already running.");
|
||||||
}
|
}
|
||||||
case STOPPING -> {
|
case STOPPING -> {
|
||||||
startingError();
|
startingError("Server is stopping");
|
||||||
logger.info("Server is stopping");
|
logger.info("Server is stopping");
|
||||||
}
|
}
|
||||||
case STOPPED, WAITING_FOR_INIT -> {
|
case STOPPED, WAITING_FOR_INIT -> {
|
||||||
|
|
@ -336,11 +338,11 @@ public abstract class AbstractWebSocketServer {
|
||||||
stopping();
|
stopping();
|
||||||
switch (ServerStatus) {
|
switch (ServerStatus) {
|
||||||
case WAITING_FOR_INIT -> {
|
case WAITING_FOR_INIT -> {
|
||||||
stoppingError();
|
stoppingError("Not Init. (It shouldn't be happened)");
|
||||||
logger.warn("Not Init. (It shouldn't be happened)");
|
logger.warn("Not Init. (It shouldn't be happened)");
|
||||||
}
|
}
|
||||||
case STARTING -> {
|
case STARTING -> {
|
||||||
stoppingError();
|
stoppingError("Server is starting, please waiting.");
|
||||||
logger.info("Server is starting, please waiting.");
|
logger.info("Server is starting, please waiting.");
|
||||||
}
|
}
|
||||||
case RUNNING -> {
|
case RUNNING -> {
|
||||||
|
|
@ -392,11 +394,11 @@ public abstract class AbstractWebSocketServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
case STOPPING -> {
|
case STOPPING -> {
|
||||||
stoppingError();
|
stoppingError("Server is already stopping");
|
||||||
logger.info("Server is already stopping");
|
logger.info("Server is already stopping");
|
||||||
}
|
}
|
||||||
case STOPPED -> {
|
case STOPPED -> {
|
||||||
stoppingError();
|
stoppingError("Server has stopped");
|
||||||
logger.info("Server has stopped");
|
logger.info("Server has stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,8 @@ public class PowerBoxWSClient extends AbstractWebSocketClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startingError() {
|
protected void startingError(String msg) {
|
||||||
operation.ClientStartingErrorHandler();
|
operation.ClientStartingErrorHandler(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -198,8 +198,8 @@ public class PowerBoxWSClient extends AbstractWebSocketClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void stoppingError() {
|
protected void stoppingError(String msg) {
|
||||||
operation.ClientStoppingErrorHandler();
|
operation.ClientStoppingErrorHandler(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,10 @@ public class PowerBoxWSServer extends AbstractWebSocketServer {
|
||||||
operation.ServerStartingHandler();
|
operation.ServerStartingHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startingError() {
|
protected void startingError(String error) {
|
||||||
operation.ServerStartingErrorHandler();
|
operation.ServerStartingErrorHandler(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -134,8 +135,8 @@ public class PowerBoxWSServer extends AbstractWebSocketServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void stoppingError() {
|
protected void stoppingError(String error) {
|
||||||
operation.ServerStoppingErrorHandler();
|
operation.ServerStoppingErrorHandler(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ public class DefaultClientOperation implements ClientOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClientStartingErrorHandler() {
|
public void ClientStartingErrorHandler(String errorMsg) {
|
||||||
//NOOP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -43,11 +43,13 @@ public class DefaultClientOperation implements ClientOperation {
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClientStoppingErrorHandler() {
|
public void ClientStoppingErrorHandler(String errorMsg) {
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ClientStoppedHandler() {
|
public void ClientStoppedHandler() {
|
||||||
//NOOP
|
//NOOP
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ public class DefaultServerOperation implements ServerOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ServerStartingErrorHandler() {
|
public void ServerStartingErrorHandler(String errorMessage) {
|
||||||
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -89,10 +89,11 @@ public class DefaultServerOperation implements ServerOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ServerStoppingErrorHandler() {
|
public void ServerStoppingErrorHandler(String errorMessage) {
|
||||||
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ServerStoppedHandler() {
|
public void ServerStoppedHandler() {
|
||||||
//NOOP
|
//NOOP
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ public interface ClientOperation extends IOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端启动遇到错误后处理
|
* 客户端启动遇到错误后处理
|
||||||
|
* @param errorMsg 错误消息
|
||||||
*/
|
*/
|
||||||
void ClientStartingErrorHandler();
|
void ClientStartingErrorHandler(String errorMsg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端线程关闭中处理
|
* 客户端线程关闭中处理
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,9 +44,9 @@ public interface ClientOperation extends IOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端线程关闭中遇到错误后处理
|
* 客户端线程关闭中遇到错误后处理
|
||||||
|
* @param errorMsg 错误消息
|
||||||
*/
|
*/
|
||||||
void ClientStoppingErrorHandler();
|
void ClientStoppingErrorHandler(String errorMsg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端线程完全关闭后处理
|
* 客户端线程完全关闭后处理
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,9 @@ public interface ServerOperation extends IOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器线程开启中遇到错误后处理
|
* 服务器线程开启中遇到错误后处理
|
||||||
|
* @param errorMessage 错误消息
|
||||||
*/
|
*/
|
||||||
void ServerStartingErrorHandler();
|
void ServerStartingErrorHandler(String errorMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器线程开启后处理
|
* 服务器线程开启后处理
|
||||||
|
|
@ -46,8 +47,9 @@ public interface ServerOperation extends IOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器线程关闭中遇到错误后处理
|
* 服务器线程关闭中遇到错误后处理
|
||||||
|
* @param errorMessage 错误消息
|
||||||
*/
|
*/
|
||||||
void ServerStoppingErrorHandler();
|
void ServerStoppingErrorHandler(String errorMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器线程完全关闭后处理
|
* 服务器线程完全关闭后处理
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ org.gradle.configuration-cache=true
|
||||||
org.gradle.configuration-cache.problems=warn
|
org.gradle.configuration-cache.problems=warn
|
||||||
# ROOT
|
# ROOT
|
||||||
project_name=DgLab
|
project_name=DgLab
|
||||||
project_version=4.2.11.18
|
project_version=4.3.11.18
|
||||||
project_group=top.r3944realms.dg_lab
|
project_group=top.r3944realms.dg_lab
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@
|
||||||
统一用4位版本,对于测试性更新统一在其后加-Beta。
|
统一用4位版本,对于测试性更新统一在其后加-Beta。
|
||||||
修复问题更新为加0.0.0.1,添加/移除新特性加0.0.1.0,小部分重构更新加0.1.0.0,大量重构加1.0.0.0
|
修复问题更新为加0.0.0.1,添加/移除新特性加0.0.1.0,小部分重构更新加0.1.0.0,大量重构加1.0.0.0
|
||||||
|
|
||||||
|
2025-09-23-1
|
||||||
|
project_version=4.3.11.18
|
||||||
|
* 添加操作Operation类的Error方法错误的参数,同时移除无参方法
|
||||||
|
*
|
||||||
|
|
||||||
2025-09-21-4
|
2025-09-21-4
|
||||||
project_version=4.2.11.18
|
project_version=4.2.11.18
|
||||||
* 添加服务器对SSL密码参数支持
|
* 添加服务器对SSL密码参数支持
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user