update SystemSetting
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.imyeyu.api.modules.music.bean;
|
||||
|
||||
import com.imyeyu.api.annotation.SettingBizType;
|
||||
import com.imyeyu.api.bean.SettingEnum;
|
||||
import com.imyeyu.api.modules.common.entity.Setting;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-04-24 14:52
|
||||
*/
|
||||
@Getter
|
||||
@SettingBizType("MUSIC")
|
||||
@AllArgsConstructor
|
||||
public enum MusicSetting implements SettingEnum {
|
||||
|
||||
/** 启用服务 */
|
||||
ENABLE(Boolean.FALSE.toString(), Setting.ValueType.BOOLEAN),
|
||||
|
||||
/** 通信消息最大帧长度 */
|
||||
MAX_FRAME_LENGTH("2048", Setting.ValueType.INTEGER),
|
||||
|
||||
/** 受控端 IP */
|
||||
PLAYER_IP("0.0.0.0", Setting.ValueType.STRING),
|
||||
|
||||
/** 受控端端口 */
|
||||
PLAYER_PORT("18392", Setting.ValueType.INTEGER),
|
||||
|
||||
/** 控制端 IP */
|
||||
CONTROLLER_IP("0.0.0.0", Setting.ValueType.STRING),
|
||||
|
||||
/** 控制端端口 */
|
||||
CONTROLLER_PORT("18391", Setting.ValueType.INTEGER),
|
||||
|
||||
/** 控制端入口地址 */
|
||||
CONTROLLER_URI("/music/control", Setting.ValueType.STRING);
|
||||
|
||||
final String defaultValue;
|
||||
|
||||
final Setting.ValueType valueType;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.imyeyu.api.modules.music.runner;
|
||||
|
||||
import com.imyeyu.api.config.CORSConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Setting;
|
||||
import com.imyeyu.api.modules.common.service.SettingService;
|
||||
import com.imyeyu.api.modules.music.bean.MusicSetting;
|
||||
import com.imyeyu.api.modules.music.handler.ControllerMessageHandler;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -62,7 +62,7 @@ public class ControllerBootstrapRunner implements ApplicationRunner, Application
|
||||
}
|
||||
|
||||
public void run(ApplicationArguments args) {
|
||||
if (settingService.getSystem(Setting.Module.Music.ENABLE).isTrue()) {
|
||||
if (settingService.getSystem(MusicSetting.ENABLE).isTrue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ControllerBootstrapRunner implements ApplicationRunner, Application
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
bootstrap.group(boss, worker);
|
||||
bootstrap.channel(NioServerSocketChannel.class);
|
||||
bootstrap.localAddress(new InetSocketAddress(settingService.getSystem(Setting.Module.Music.CONTROLLER_PORT).asInteger()));
|
||||
bootstrap.localAddress(new InetSocketAddress(settingService.getSystem(MusicSetting.CONTROLLER_PORT).asInteger()));
|
||||
bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
@@ -89,7 +89,7 @@ public class ControllerBootstrapRunner implements ApplicationRunner, Application
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object obj) throws Exception {
|
||||
if (obj instanceof FullHttpRequest req) {
|
||||
if (!req.uri().equals(settingService.getSystem(Setting.Module.Music.CONTROLLER_URI).asString())) {
|
||||
if (!req.uri().equals(settingService.getSystem(MusicSetting.CONTROLLER_URI).asString())) {
|
||||
// 访问的路径不是 Web Socket 的端点地址,响应 404
|
||||
ctx.channel().writeAndFlush(NFP).addListener(ChannelFutureListener.CLOSE);
|
||||
return;
|
||||
@@ -111,10 +111,10 @@ public class ControllerBootstrapRunner implements ApplicationRunner, Application
|
||||
});
|
||||
pipeline.addLast(new WebSocketServerCompressionHandler());
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(
|
||||
settingService.getSystem(Setting.Module.Music.CONTROLLER_URI).asString(),
|
||||
settingService.getSystem(MusicSetting.CONTROLLER_URI).asString(),
|
||||
null,
|
||||
true,
|
||||
settingService.getSystem(Setting.Module.Music.MAX_FRAME_LENGTH).asLong()
|
||||
settingService.getSystem(MusicSetting.MAX_FRAME_LENGTH).asLong()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ControllerBootstrapRunner implements ApplicationRunner, Application
|
||||
}
|
||||
});
|
||||
channel = bootstrap.bind().sync().channel();
|
||||
log.info("TimiMusicRC controller service startup with {}", settingService.getSystem(Setting.Module.Music.CONTROLLER_IP).asString());
|
||||
log.info("TimiMusicRC controller service startup with {}", settingService.getSystem(MusicSetting.CONTROLLER_IP).asString());
|
||||
} catch (Exception e) {
|
||||
log.error("TimiMusicRC controller service startup error", e);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.imyeyu.api.modules.music.runner;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Setting;
|
||||
import com.imyeyu.api.modules.common.service.SettingService;
|
||||
import com.imyeyu.api.modules.music.bean.MusicSetting;
|
||||
import com.imyeyu.api.modules.music.handler.PlayerMessageHandler;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -49,7 +49,7 @@ public class PlayerBootstrapRunner implements ApplicationRunner, ApplicationList
|
||||
}
|
||||
|
||||
public void run(ApplicationArguments args) {
|
||||
if (settingService.getSystem(Setting.Module.Music.ENABLE).isTrue()) {
|
||||
if (settingService.getSystem(MusicSetting.ENABLE).isTrue()) {
|
||||
return;
|
||||
}
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
@@ -58,13 +58,13 @@ public class PlayerBootstrapRunner implements ApplicationRunner, ApplicationList
|
||||
try {
|
||||
bootstrap.group(boss, worker);
|
||||
bootstrap.channel(NioServerSocketChannel.class);
|
||||
bootstrap.localAddress(new InetSocketAddress(settingService.getSystem(Setting.Module.Music.PLAYER_PORT).asInteger()));
|
||||
bootstrap.localAddress(new InetSocketAddress(settingService.getSystem(MusicSetting.PLAYER_PORT).asInteger()));
|
||||
bootstrap.childHandler(new ChannelInitializer<>() {
|
||||
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(
|
||||
settingService.getSystem(Setting.Module.Music.MAX_FRAME_LENGTH).asInteger(),
|
||||
settingService.getSystem(MusicSetting.MAX_FRAME_LENGTH).asInteger(),
|
||||
0,
|
||||
4,
|
||||
0,
|
||||
@@ -79,7 +79,7 @@ public class PlayerBootstrapRunner implements ApplicationRunner, ApplicationList
|
||||
|
||||
channel = bootstrap.bind().sync().channel();
|
||||
|
||||
log.info("TimiMusicRC player service startup with {}", settingService.getSystem(Setting.Module.Music.PLAYER_IP).asString());
|
||||
log.info("TimiMusicRC player service startup with {}", settingService.getSystem(MusicSetting.PLAYER_IP).asString());
|
||||
} catch (Exception e) {
|
||||
log.error("TimiMusicRC player service startup error", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user