Skip to content

Commit fb191e8

Browse files
committed
Merge commit '2e965dbf2eec46e1d71b1a676c68965bbc09ede7' into develop
2 parents 9712866 + 2e965db commit fb191e8

67 files changed

Lines changed: 950 additions & 692 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

framework/core/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,11 @@
131131
- It should force to close sessions and disconnect players in some scenarios
132132

133133
## 0.7.2 2026-04-25 Feature release
134-
- Fixed issues which caused theGame Server takes time to shut down
134+
- Fixed issues which caused the Game Server takes time to shut down
135+
136+
## 0.7.3 2026-05-29 Feature release
137+
- Fixed several issues in ServerApi
138+
- Improved the performance by offloading tasks from IO bound workers
139+
- Used EnumMap in EventHandler to increase lookup speed
140+
- Supported multi UDP channels
141+
- Renamed and added new APIs

framework/core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Maven Central
108108
<dependency>
109109
<groupId>io.github.congcoi123</groupId>
110110
<artifactId>tenio-core</artifactId>
111-
<version>0.7.2</version>
111+
<version>0.7.3</version>
112112
</dependency>
113113
```
114114
GitHub

framework/core/TODO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
### TODO LIST
2-
- [ ] Makes proper session reconnection handling
2+
- [ ] Makes proper session reconnection handling
3+
- [ ] Players should own its inbound queue in case we need to create NPC on server

framework/core/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20260425.0.7.2
1+
20260529.0.7.3

framework/core/configuration.example.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@
2424
- Use 1 or let the cacheSize to be absent on macOS/Windows (SO_REUSEPORT not reliable).
2525
- On Linux, increase for better load balancing if SO_REUSEPORT is enabled.
2626
-->
27-
<Port name="udp" type="udp" cacheSize="100">20004</Port>
27+
<Port name="udp" type="udp" cacheSize="10">20004</Port>
2828
<Port name="http" type="http">9999</Port>
2929
</Sockets>
3030
<Properties>
3131
<Property name="websocket-using-ssl">false</Property>
32-
<Property name="websocket-sender-buffer-size">1024</Property>
33-
<Property name="websocket-receiver-buffer-size">1024</Property>
34-
<Property name="socket-acceptor-buffer-size">1024</Property>
35-
<Property name="socket-reader-buffer-size">1024</Property>
36-
<Property name="socket-writer-buffer-size">1024</Property>
32+
<!--
33+
1 KB -> 1024
34+
8 KB -> 8192
35+
16 KB -> 16384
36+
32 KB -> 32768
37+
-->
38+
<Property name="websocket-sender-buffer-size">1024</Property> <!-- 1KB -->
39+
<Property name="websocket-receiver-buffer-size">1024</Property> <!-- 1KB -->
40+
<Property name="socket-acceptor-buffer-size">1024</Property> <!-- 1KB -->
41+
<Property name="socket-reader-buffer-size">1024</Property> <!-- 1KB -->
42+
<Property name="socket-writer-buffer-size">1024</Property> <!-- 1KB -->
3743
<!-- This will never compress packets if the threshold is less than or equals to 0 -->
3844
<Property name="packet-compression-threshold-bytes">10240</Property>
3945
<Property name="allow-change-session">false</Property>
@@ -43,7 +49,10 @@
4349

4450
<Configuration>
4551
<Workers>
46-
<Worker name="socket-reader">1</Worker>
52+
<!-- The processor handle socket and datagram connection requests -->
53+
<Worker name="processor">1</Worker>
54+
<!-- In case udp channel is in use, half of the socket-reader workers will be used for them -->
55+
<Worker name="socket-reader">4</Worker>
4756
<Worker name="socket-writer">2</Worker>
4857
<Worker name="websocket-producer">1</Worker>
4958
<Worker name="websocket-consumer">2</Worker>

framework/core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>io.github.congcoi123</groupId>
77
<artifactId>tenio-core</artifactId>
8-
<version>0.7.2</version>
8+
<version>0.7.3</version>
99
<packaging>jar</packaging>
1010

1111
<name>${project.groupId}:${project.artifactId}</name>
@@ -42,15 +42,15 @@
4242
<io.github.congcoi123.tenio.common>0.7.0</io.github.congcoi123.tenio.common>
4343

4444
<io.netty.version>4.2.12.Final</io.netty.version>
45-
<org.eclipse.jetty.server.version>12.1.6</org.eclipse.jetty.server.version>
45+
<org.eclipse.jetty.server.version>12.1.7</org.eclipse.jetty.server.version>
4646
<org.eclipse.jetty.ee10.servlet.version>12.1.6</org.eclipse.jetty.ee10.servlet.version>
4747
<jakarta.servlet.api.version>6.1.0</jakarta.servlet.api.version>
4848
<javax.servlet.version>2.5</javax.servlet.version>
4949
<org.jline.version>3.30.9</org.jline.version>
5050
<org.apache.commons.lang3.version>3.19.0</org.apache.commons.lang3.version>
5151
<org.apache.httpcomponents.httpcore.version>4.4.16</org.apache.httpcomponents.httpcore.version>
5252

53-
<logging.log4j.version>2.25.3</logging.log4j.version>
53+
<logging.log4j.version>2.25.4</logging.log4j.version>
5454

5555
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5656

framework/core/src/main/java/com/tenio/core/api/ServerApi.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ default Room createRoom(InitialRoomSetting roomSetting) {
174174
Optional<Player> getPlayerByIdentity(String identity);
175175

176176
/**
177-
* Fetches the current number of players activating on the server.
177+
* Retrieves the snapshot of the number of players in the management list.
178+
* This is expected to provide the most recent update of the player count.
179+
* This operation is thread-safe and provides an atomic count.
178180
*
179-
* @return the current number of players ({@code integer} value)
180-
* @since 0.5.0
181+
* @return the most recent update of the number of players in the list
182+
* @since 0.7.3
181183
*/
182-
int getPlayerCount();
184+
int getSnapshotPlayerCount();
183185

184186
/**
185187
* Ensures the calculation on the player list is thread-safe.
@@ -190,14 +192,17 @@ default Room createRoom(InitialRoomSetting roomSetting) {
190192
void computePlayers(Consumer<Iterator<Player>> onComputed);
191193

192194
/**
193-
* Retrieves a read-only global player management list on the server. This method should be used
194-
* to prevent the "escape references" issue.
195+
* Retrieves a snapshot of the read-only player management list.
196+
* This is expected to provide the most recent update of the player list.
197+
* This method should be used to prevent the "escape references" issue
198+
* and provides thread-safe access to the player collection.
195199
*
196-
* @return a list of all {@link Player}s in the management list on the server
200+
* @return the recent update of the list of all {@link Player}s in the management list
197201
* @see PlayerManager
198202
* @see List
203+
* @since 0.7.3
199204
*/
200-
List<Player> getReadonlyPlayersList();
205+
List<Player> getSnapshotPlayersList();
201206

202207
/**
203208
* Retrieves a room instance by using its ID.
@@ -217,21 +222,22 @@ default Room createRoom(InitialRoomSetting roomSetting) {
217222
void computeRooms(Consumer<Iterator<Room>> onComputed);
218223

219224
/**
220-
* Retrieves a read-only global room management list on the server. This method should be used
221-
* to prevent the "escape references" issue.
225+
* Retrieves the most recent rooms in the room management list.
222226
*
223-
* @return a list of all rooms {@link Room} in the management list on the server
227+
* @return a most recent up-to-date list of all {@link Room}s in the management list
224228
* @see RoomManager
225229
* @see List
230+
* @since 0.7.3
226231
*/
227-
List<Room> getReadonlyRoomsList();
232+
List<Room> getSnapshotRoomsList();
228233

229234
/**
230-
* Fetches the current number of rooms on the server.
235+
* Fetches the most recent number of rooms in the management list.
231236
*
232-
* @return the current number of rooms ({@code integer} value)
237+
* @return the most recent number of rooms ({@code integer} value)
238+
* @since 0.7.3
233239
*/
234-
int getRoomCount();
240+
int getSnapshotRoomCount();
235241

236242
/**
237243
* Allows a player to join a particular room.

framework/core/src/main/java/com/tenio/core/api/implement/ServerApiImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void logout(Player player, ConnectionDisconnectMode connectionDisconnectM
104104
}
105105

106106
try {
107-
if (player.containsSession() && player.getSession().isPresent()) {
107+
if (player.containsSession() && player.getSession().isPresent() && player.getSession().get().isActivated()) {
108108
// check process on method ZeroProcessorImpl#processSessionWillBeClosed
109109
Session session = player.getSession().get();
110110
session.close(connectionDisconnectMode, playerDisconnectMode);
@@ -175,8 +175,8 @@ public Optional<Player> getPlayerByIdentity(String identity) {
175175
}
176176

177177
@Override
178-
public int getPlayerCount() {
179-
return getPlayerManager().getPlayerCount();
178+
public int getSnapshotPlayerCount() {
179+
return getPlayerManager().getSnapshotPlayerCount();
180180
}
181181

182182
@Override
@@ -185,8 +185,8 @@ public void computePlayers(Consumer<Iterator<Player>> onComputed) {
185185
}
186186

187187
@Override
188-
public List<Player> getReadonlyPlayersList() {
189-
return getPlayerManager().getReadonlyPlayersList();
188+
public List<Player> getSnapshotPlayersList() {
189+
return getPlayerManager().getSnapshotPlayersList();
190190
}
191191

192192
@Override
@@ -200,13 +200,13 @@ public void computeRooms(Consumer<Iterator<Room>> onComputed) {
200200
}
201201

202202
@Override
203-
public List<Room> getReadonlyRoomsList() {
204-
return getRoomManager().getReadonlyRoomsList();
203+
public List<Room> getSnapshotRoomsList() {
204+
return getRoomManager().getSnapshotRoomsList();
205205
}
206206

207207
@Override
208-
public int getRoomCount() {
209-
return getRoomManager().getRoomCount();
208+
public int getSnapshotRoomCount() {
209+
return getRoomManager().getSnapshotRoomCount();
210210
}
211211

212212
@Override

framework/core/src/main/java/com/tenio/core/command/system/implement/InfoCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public void execute(List<String> arguments) {
4747
switch (action) {
4848
case "player":
4949
CommandUtility.INSTANCE.showConsoleMessage(
50-
"There are " + api().getPlayerCount() + " players > The first 10 entities > " +
51-
api().getReadonlyPlayersList().subList(0, Math.min(api().getPlayerCount(), 10)));
50+
"There are " + api().getSnapshotPlayerCount() + " players > The first 10 entities > " +
51+
api().getSnapshotPlayersList().subList(0, Math.min(api().getSnapshotPlayerCount(), 10)));
5252
break;
5353

5454
case "room":
55-
var rooms = api().getReadonlyRoomsList();
55+
var rooms = api().getSnapshotRoomsList();
5656
CommandUtility.INSTANCE.showConsoleMessage(
5757
"There are " + rooms.size() + " rooms > The first 10 entities > " +
5858
rooms.subList(0, Math.min(rooms.size(), 10)));

framework/core/src/main/java/com/tenio/core/configuration/constant/CoreConstant.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ of this software and associated documentation files (the "Software"), to deal
2525
package com.tenio.core.configuration.constant;
2626

2727
import com.tenio.core.network.zero.engine.ZeroAcceptor;
28-
import com.tenio.core.server.core.ZeroProcessor;
2928

3029
/**
3130
* Defines core constants used throughout the server application.
@@ -143,14 +142,6 @@ public final class CoreConstant {
143142
*/
144143
public static final int DELAY_BEFORE_SERVER_IS_READY_IN_MILLISECONDS = 100;
145144

146-
/**
147-
* The default thread pool size of processor.
148-
*
149-
* @see ZeroProcessor
150-
* @since 0.7.0
151-
*/
152-
public static final int DEFAULT_PROCESSOR_THREAD_POOL_SIZE = 1;
153-
154145
/**
155146
* The default thread pool size of engine.
156147
*

0 commit comments

Comments
 (0)