mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Moved validation to TikTokLiveClientBuilder#validate!
This commit is contained in:
@@ -86,18 +86,10 @@ public class LiveClientSettings {
|
|||||||
private HttpClientSettings httpSettings;
|
private HttpClientSettings httpSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop time in milliseconds between pings to TikTok
|
* Interval of time in milliseconds between pings to TikTok
|
||||||
* @apiNote Min: 250 (0.25 seconds), Max: 30000 (30 seconds), Default: 5000 (5 seconds)
|
* @apiNote Min: 250 (0.25 seconds), Default: 5000 (5 seconds)
|
||||||
*/
|
*/
|
||||||
private long pingTaskTime = 5000;
|
private long pingInterval = 5000;
|
||||||
|
|
||||||
public void setPingTaskTime(long pingTaskTime) {
|
|
||||||
if (pingTaskTime < 250)
|
|
||||||
throw new IllegalArgumentException("Minimum allowed value 250 millseconds");
|
|
||||||
if (pingTaskTime > 30000)
|
|
||||||
throw new IllegalArgumentException("Maximum allowed value 30000 milliseconds");
|
|
||||||
this.pingTaskTime = pingTaskTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional: Sometimes not every messages from chat are send to TikTokLiveJava to fix this issue you can set sessionId
|
* Optional: Sometimes not every messages from chat are send to TikTokLiveJava to fix this issue you can set sessionId
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
|||||||
if (clientSettings.getHostName().startsWith("@"))
|
if (clientSettings.getHostName().startsWith("@"))
|
||||||
clientSettings.setHostName(clientSettings.getHostName().substring(1));
|
clientSettings.setHostName(clientSettings.getHostName().substring(1));
|
||||||
|
|
||||||
|
if (clientSettings.getPingInterval() < 250)
|
||||||
|
throw new TikTokLiveException("Minimum allowed ping interval is 250 millseconds");
|
||||||
|
|
||||||
var httpSettings = clientSettings.getHttpSettings();
|
var httpSettings = clientSettings.getHttpSettings();
|
||||||
httpSettings.getParams().put("app_language", clientSettings.getClientLanguage());
|
httpSettings.getParams().put("app_language", clientSettings.getClientLanguage());
|
||||||
httpSettings.getParams().put("webcast_language", clientSettings.getClientLanguage());
|
httpSettings.getParams().put("webcast_language", clientSettings.getClientLanguage());
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
private void connectDefault() {
|
private void connectDefault() {
|
||||||
try {
|
try {
|
||||||
webSocketClient.connect();
|
webSocketClient.connect();
|
||||||
pingingTask.run(webSocketClient, clientSettings.getPingTaskTime());
|
pingingTask.run(webSocketClient, clientSettings.getPingInterval());
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
@@ -112,7 +112,7 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
proxySettings.remove();
|
proxySettings.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pingingTask.run(webSocketClient, clientSettings.getPingTaskTime());
|
pingingTask.run(webSocketClient, clientSettings.getPingInterval());
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user