Skip to content

Commit

Permalink
update Base64 and Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
tvd12 committed Aug 7, 2021
1 parent 9eb78a4 commit 645c6cd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ public final void handle(EzyConnectionFailureEvent event) {
client.setStatus(EzyConnectionStatus.FAILURE);
if(mustReconnect)
reconnecting = client.reconnect();
if(!reconnecting) {
control(event);
if(reconnecting) {
onReconnecting(event);
}
else {
onConnectionFailed(event);
}
postHandle(event);
}

protected boolean shouldReconnect(EzyConnectionFailureEvent event) {
return true;
}

protected void control(EzyConnectionFailureEvent event) {
}
protected void onReconnecting(EzyConnectionFailureEvent event) { }
protected void onConnectionFailed(EzyConnectionFailureEvent event) { }
protected void postHandle(EzyConnectionFailureEvent event) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ public final void handle(EzyDisconnectionEvent event) {
client.setStatus(EzyConnectionStatus.DISCONNECTED);
if(mustReconnect)
reconnecting = client.reconnect();
if(!reconnecting) {
control(event);
if(reconnecting) {
onReconnecting(event);
}
else {
onDisconnected(event);
}
postHandle(event);
}

protected void preHandle(EzyDisconnectionEvent event) { }
protected void onReconnecting(EzyDisconnectionEvent event) { }
protected void onDisconnected(EzyDisconnectionEvent event) { }
protected void postHandle(EzyDisconnectionEvent event) { }

protected boolean shouldReconnect(EzyDisconnectionEvent event) {
Expand All @@ -46,7 +51,4 @@ protected boolean shouldReconnect(EzyDisconnectionEvent event) {
}
return true;
}

protected void control(EzyDisconnectionEvent event) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ private EzyBase64() {
}

public static byte[] encode(byte[] input) {
byte[] answer = Base64.encode(input, Base64.DEFAULT);
byte[] answer = Base64.encode(input, Base64.NO_WRAP);
return answer;
}

public static byte[] decode(byte[] input) {
byte[] answer = Base64.decode(input, Base64.DEFAULT);
byte[] answer = Base64.decode(input, Base64.NO_WRAP);
return answer;
}

public static byte[] decode(String input) {
byte[] answer = Base64.decode(input, Base64.DEFAULT);
byte[] answer = Base64.decode(input, Base64.NO_WRAP);
return answer;
}

public static byte[] encode(String input) {
byte[] bytes = EzyStrings.getUtfBytes(input);
byte[] answer = Base64.encode(bytes, Base64.DEFAULT);
byte[] answer = Base64.encode(bytes, Base64.NO_WRAP);
return answer;
}

public static String encodeUtf(String input) {
byte[] bytes = EzyStrings.getUtfBytes(input);
String answer = Base64.encodeToString(bytes, Base64.DEFAULT);
String answer = Base64.encodeToString(bytes, Base64.NO_WRAP);
return answer;
}

public static String decodeUtf(String input) {
byte[] bytes = Base64.decode(input, Base64.DEFAULT);
byte[] bytes = Base64.decode(input, Base64.NO_WRAP);
String answer = EzyStrings.newUtf(bytes);
return answer;
}
Expand Down

0 comments on commit 645c6cd

Please sign in to comment.