Skip to content

Commit f9f6451

Browse files
committed
优化了部分格式
添加了部分javadoc内容
1 parent c18b350 commit f9f6451

32 files changed

+512
-399
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build/
33
!gradle/wrapper/gradle-wrapper.jar
44
!**/src/main/**/build/
55
!**/src/test/**/build/
6-
6+
logs/
77
### IntelliJ IDEA ###
88
.idea/modules.xml
99
.idea/jarRepositories.xml
@@ -40,4 +40,4 @@ bin/
4040

4141
### Mac OS ###
4242
.DS_Store
43-
/logs/
43+

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
如何启动服务器&客户端;
2-
启动服务器:
1+
# 如何启动服务器&客户端;
2+
启动客户端:
33
```Java
44
public class Client {
55
public static void main(String[] args) {
@@ -8,20 +8,46 @@ public class Client {
88
//connect to other address and port, do such that:
99
//new PowerBoxWSClient(sharedData, new WebSocketServerRole("IWebsocketServer"), "<Server Address>", <port>)
1010
DGPBClientManager dgpbClientManager = new DGPBClientManager(powerBoxWSClient);
11+
//以客户端管理器方式接管客户端进程启动
1112
dgpbClientManager.start();
1213
}
1314
}
1415
````
15-
Start Server:
16+
启动服务器:
1617
```Java
1718
public class Server {
1819
public static void main(String[] args) {
20+
//服务器运行时所向外暴露的共享数据
1921
ServerPowerBoxSharedData sharedData = new ServerPowerBoxSharedData();
2022
PowerBoxWSServer powerBoxWSServer = new PowerBoxWSServer(sharedData, new WebSocketServerRole("IWebsocketServer"));
2123
//start on other port, like 10000, do such that:
2224
//new PowerBoxWSServer(sharedData, new WebSocketServerRole("IWebsocketServer"), 10000)
25+
//你也可以以直接让服务器进程启动
26+
powerBoxWSServer.start();
27+
}
28+
}
29+
````
30+
## 解释
31+
要通过此框架来实现服务器和客户端启动,首先得知道构成一个ClientServer封装类构造器的一些参数:<br/>
32+
建议是使用对应xxxServer(或Client)下的Builder类来获取对应封装类的实例;
33+
```Java
34+
public class Server {
35+
public static void main(String[] args) {
36+
ServerPowerBoxSharedData sharedData = new ServerPowerBoxSharedData();
37+
PowerBoxWSServer powerBoxWSServer = PowerBoxWSServer.Builder.getBuilder()
38+
//设置共享数据
39+
.sharedData(sharedData)
40+
//设置角色,用于信息验证
41+
.role(new WebSocketServerRole("IWebsocketServer"))
42+
//设置服务器进程运行端口
43+
.port(9000)
44+
.build();
45+
//将服务器进程托管给相应的管理器
46+
DGPBServerManager dgpbServerManager = new DGPBServerManager(powerBoxWSServer);
47+
//启动
2348
powerBoxWSServer.start();
2449
}
2550
}
2651
````
27-
___More about it read its code___
52+
53+
___更多有关内容请阅读源代码___

logs/dg_lab/error.2025-02-27.log

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
2025-02-27 11:14:37.736 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
2-
2025-02-27 11:18:23.379 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
3-
2025-02-27 11:23:20.966 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
4-
2025-02-27 11:24:28.225 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
5-
2025-02-27 15:08:30.189 [nioEventLoopGroup-3-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.HttpRequestHandler - Connection reset
1+
2025-02-27 11:14:37.736 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.handler.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
2+
2025-02-27 11:18:23.379 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.handler.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
3+
2025-02-27 11:23:20.966 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.handler.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
4+
2025-02-27 11:24:28.225 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.handler.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
5+
2025-02-27 15:08:30.189 [nioEventLoopGroup-3-1] ERROR com.r3944realms.dg_lab.websocket.handler.HttpRequestHandler - Connection reset
66
java.net.SocketException: Connection reset
77
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:394)
88
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:426)
@@ -18,7 +18,7 @@ java.net.SocketException: Connection reset
1818
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
1919
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2020
at java.base/java.lang.Thread.run(Thread.java:840)
21-
2025-02-27 15:14:52.803 [nioEventLoopGroup-3-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.HttpRequestHandler - Connection reset
21+
2025-02-27 15:14:52.803 [nioEventLoopGroup-3-1] ERROR com.r3944realms.dg_lab.websocket.handler.HttpRequestHandler - Connection reset
2222
java.net.SocketException: Connection reset
2323
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:394)
2424
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:426)
@@ -34,7 +34,7 @@ java.net.SocketException: Connection reset
3434
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
3535
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
3636
at java.base/java.lang.Thread.run(Thread.java:840)
37-
2025-02-27 15:22:30.127 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.hanlder.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
37+
2025-02-27 15:22:30.127 [nioEventLoopGroup-2-1] ERROR com.r3944realms.dg_lab.websocket.handler.AbstractDgLabPowerBoxHandler - 连接出现错误:Connection reset
3838
2025-02-27 15:33:35.768 [Thread-0] ERROR com.r3944realms.dg_lab.websocket.AbstractWebSocketClient - Connection refused: no further information: /192.168.1.107:9000
3939
2025-02-27 15:34:02.055 [Thread-0] ERROR com.r3944realms.dg_lab.websocket.AbstractWebSocketClient - Connection refused: no further information: /192.168.1.107:9000
4040
2025-02-27 15:34:12.534 [Thread-0] ERROR com.r3944realms.dg_lab.websocket.AbstractWebSocketClient - Connection refused: no further information: /192.168.1.107:9000

0 commit comments

Comments
 (0)