mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Remove -1 close code and convert to standard public static value with reference!
This commit is contained in:
@@ -30,6 +30,8 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Control)
|
@EventMeta(eventType = EventType.Control)
|
||||||
public class TikTokDisconnectedEvent extends TikTokLiveClientEvent {
|
public class TikTokDisconnectedEvent extends TikTokLiveClientEvent {
|
||||||
|
public static int UNKNOWN_CLOSE_CODE = -1;
|
||||||
|
|
||||||
/** Valid CloseFrame code or -1 for unknown */
|
/** Valid CloseFrame code or -1 for unknown */
|
||||||
private final int code;
|
private final int code;
|
||||||
private final String reason;
|
private final String reason;
|
||||||
@@ -38,4 +40,12 @@ public class TikTokDisconnectedEvent extends TikTokLiveClientEvent {
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
this.reason = reason.isBlank() ? "None" : reason;
|
this.reason = reason.isBlank() ? "None" : reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TikTokDisconnectedEvent(String reason) {
|
||||||
|
this(UNKNOWN_CLOSE_CODE, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnknownCloseCode() {
|
||||||
|
return this.code == UNKNOWN_CLOSE_CODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class TikTokLiveClient implements LiveClient
|
|||||||
} catch (TikTokLiveException e) {
|
} catch (TikTokLiveException e) {
|
||||||
setState(ConnectionState.DISCONNECTED);
|
setState(ConnectionState.DISCONNECTED);
|
||||||
tikTokEventHandler.publish(this, new TikTokErrorEvent(e));
|
tikTokEventHandler.publish(this, new TikTokErrorEvent(e));
|
||||||
tikTokEventHandler.publish(this, new TikTokDisconnectedEvent(-1, "Exception: " + e.getMessage()));
|
tikTokEventHandler.publish(this, new TikTokDisconnectedEvent("Exception: " + e.getMessage()));
|
||||||
|
|
||||||
if (e instanceof TikTokLiveOfflineHostException && clientSettings.isRetryOnConnectionFailure()) {
|
if (e instanceof TikTokLiveOfflineHostException && clientSettings.isRetryOnConnectionFailure()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class TikTokWebSocketOfflineClient implements LiveSocketClient {
|
|||||||
@Override
|
@Override
|
||||||
public void stop(int type) {
|
public void stop(int type) {
|
||||||
if (liveClient != null)
|
if (liveClient != null)
|
||||||
handler.publish(liveClient, new TikTokDisconnectedEvent(-1, "Stopping"));
|
handler.publish(liveClient, new TikTokDisconnectedEvent("Stopping"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user