Skip to content

Commit 53089e6

Browse files
authored
Add event loop group (#17)
* ssl * ssl * update customization ssl (#15) * update customization ssl * update * reduce log level * update udp codec (#16) * update setSessionKey * update for udp * add even loop group * update
1 parent f67418a commit 53089e6

File tree

95 files changed

+2946
-397
lines changed

Some content is hidden

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

95 files changed

+2946
-397
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<artifactId>ezyfox-server-java-client</artifactId>
1313

14-
<version>1.2.5</version>
14+
<version>1.2.6</version>
1515
<name>ezyfox-server-java-client</name>
1616
<url>https://youngmonkeys.org/</url>
1717

src/main/java/com/tvd12/ezyfoxserver/client/EzyClient.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.tvd12.ezyfoxserver.client.constant.EzyCommand;
77
import com.tvd12.ezyfoxserver.client.constant.EzyConnectionStatus;
88
import com.tvd12.ezyfoxserver.client.constant.EzyDisconnectReason;
9+
import com.tvd12.ezyfoxserver.client.constant.EzySslType;
910
import com.tvd12.ezyfoxserver.client.entity.EzyApp;
1011
import com.tvd12.ezyfoxserver.client.entity.EzyUser;
1112
import com.tvd12.ezyfoxserver.client.entity.EzyZone;
@@ -16,6 +17,8 @@
1617
import com.tvd12.ezyfoxserver.client.socket.EzyPingSchedule;
1718
import com.tvd12.ezyfoxserver.client.socket.EzySocketClient;
1819

20+
import javax.net.ssl.SSLContext;
21+
1922
public interface EzyClient extends EzyCloseable {
2023

2124
EzySetup setup();
@@ -24,11 +27,15 @@ public interface EzyClient extends EzyCloseable {
2427

2528
boolean reconnect();
2629

27-
void send(EzyRequest request);
30+
default void send(EzyRequest request) {
31+
send(request, false);
32+
}
2833

2934
void send(EzyRequest request, boolean encrypted);
3035

31-
void send(EzyCommand cmd, EzyArray data);
36+
default void send(EzyCommand cmd, EzyArray data) {
37+
send(cmd, data, false);
38+
}
3239

3340
void send(EzyCommand cmd, EzyArray data, boolean encrypted);
3441

@@ -44,9 +51,17 @@ default void disconnect() {
4451

4552
void udpConnect(String host, int port);
4653

47-
void udpSend(EzyRequest request);
54+
default void udpSend(EzyRequest request) {
55+
udpSend(request, false);
56+
}
57+
58+
void udpSend(EzyRequest request, boolean encrypted);
4859

49-
void udpSend(EzyCommand cmd, EzyArray data);
60+
default void udpSend(EzyCommand cmd, EzyArray data) {
61+
udpSend(cmd, data, false);
62+
}
63+
64+
void udpSend(EzyCommand cmd, EzyArray data, boolean encrypted);
5065

5166
void close();
5267

@@ -56,6 +71,14 @@ default void disconnect() {
5671

5772
boolean isEnableSSL();
5873

74+
EzySslType getSslType();
75+
76+
boolean isEnableEncryption();
77+
78+
boolean isEnableCertificationSSL();
79+
80+
void setSslContext(SSLContext sslContext);
81+
5982
boolean isEnableDebug();
6083

6184
EzyUser getMe();

src/main/java/com/tvd12/ezyfoxserver/client/EzyClients.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import com.tvd12.ezyfoxserver.client.config.EzyClientConfig;
44
import com.tvd12.ezyfoxserver.client.constant.EzyTransportType;
55

6+
import java.util.ArrayList;
67
import java.util.HashMap;
78
import java.util.List;
89
import java.util.Map;
910

11+
import static com.tvd12.ezyfox.util.EzyProcessor.processWithLogException;
12+
1013
public final class EzyClients {
1114

1215
private String defaultClientName;
@@ -28,7 +31,8 @@ public EzyClient newClient(EzyClientConfig config) {
2831

2932
public EzyClient newClient(
3033
EzyTransportType transportType,
31-
EzyClientConfig config) {
34+
EzyClientConfig config
35+
) {
3236
synchronized (clients) {
3337
return doNewClient(transportType, config);
3438
}
@@ -46,9 +50,6 @@ private EzyClient doNewClient(
4650
client = new EzyUTClient(config);
4751
}
4852
doAddClient(client);
49-
if (defaultClientName == null) {
50-
defaultClientName = client.getName();
51-
}
5253
}
5354
return client;
5455
}
@@ -112,6 +113,9 @@ public void getClients(List<EzyClient> cachedClients) {
112113
public void removeClient(String name) {
113114
synchronized (clients) {
114115
clients.remove(name);
116+
if (name.equals(defaultClientName)) {
117+
defaultClientName = null;
118+
}
115119
}
116120
}
117121

@@ -120,4 +124,12 @@ public void clear() {
120124
this.clients.clear();
121125
}
122126
}
127+
128+
public void disconnectClients() {
129+
List<EzyClient> clientsToDisconnect = new ArrayList<>();
130+
getClients(clientsToDisconnect);
131+
clientsToDisconnect.forEach(it ->
132+
processWithLogException(it::disconnect)
133+
);
134+
}
123135
}

0 commit comments

Comments
 (0)