Skip to content

Commit f1a0047

Browse files
authored
Merge pull request #13 from youngmonkeys/dev
update handlers
2 parents af42309 + c69873b commit f1a0047

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
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.1.4</version>
14+
<version>1.1.5</version>
1515
<name>ezyfox-server-java-client</name>
1616
<url>https://youngmonkeys.org/</url>
1717

src/main/java/com/tvd12/ezyfoxserver/client/handler/EzyConnectionFailureHandler.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ public final void handle(EzyConnectionFailureEvent event) {
2222
client.setStatus(EzyConnectionStatus.FAILURE);
2323
if(mustReconnect)
2424
reconnecting = client.reconnect();
25-
if(!reconnecting) {
26-
control(event);
25+
if(reconnecting) {
26+
onReconnecting(event);
2727
}
28+
else {
29+
onConnectionFailed(event);
30+
}
31+
postHandle(event);
2832
}
2933

3034
protected boolean shouldReconnect(EzyConnectionFailureEvent event) {
3135
return true;
3236
}
3337

34-
protected void control(EzyConnectionFailureEvent event) {
35-
}
38+
protected void onReconnecting(EzyConnectionFailureEvent event) {}
39+
40+
protected void onConnectionFailed(EzyConnectionFailureEvent event) {}
41+
42+
protected void postHandle(EzyConnectionFailureEvent event) {}
3643
}

src/main/java/com/tvd12/ezyfoxserver/client/handler/EzyDisconnectionHandler.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ public final void handle(EzyDisconnectionEvent event) {
3030
client.setUdpStatus(EzyConnectionStatus.DISCONNECTED);
3131
if(mustReconnect)
3232
reconnecting = client.reconnect();
33-
if(!reconnecting) {
34-
control(event);
33+
if(reconnecting) {
34+
onReconnecting(event);
35+
}
36+
else {
37+
onDisconnected(event);
3538
}
3639
postHandle(event);
3740
}
3841

3942
protected void preHandle(EzyDisconnectionEvent event) {}
43+
44+
protected void onReconnecting(EzyDisconnectionEvent event) {}
45+
46+
protected void onDisconnected(EzyDisconnectionEvent event) {}
47+
4048
protected void postHandle(EzyDisconnectionEvent event) {}
4149

4250
protected boolean shouldReconnect(EzyDisconnectionEvent event) {
@@ -45,6 +53,4 @@ protected boolean shouldReconnect(EzyDisconnectionEvent event) {
4553
return false;
4654
return true;
4755
}
48-
49-
protected void control(EzyDisconnectionEvent event) {}
5056
}

0 commit comments

Comments
 (0)