mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Add settings for allowing proxies to be used for working through Websockets.
This commit is contained in:
@@ -33,7 +33,7 @@ import java.util.function.Consumer;
|
||||
@Setter
|
||||
public class ProxyClientSettings implements Iterator<ProxyData>, Iterable<ProxyData>
|
||||
{
|
||||
private boolean enabled, autoDiscard = true, fallback = true;
|
||||
private boolean enabled, autoDiscard = true, fallback = true, allowWebsocket = true;
|
||||
private Rotation rotation = Rotation.CONSECUTIVE;
|
||||
private final List<ProxyData> proxyList = new ArrayList<>();
|
||||
private int index;
|
||||
|
||||
@@ -74,10 +74,10 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
||||
tikTokEventHandler,
|
||||
liveClient);
|
||||
|
||||
// ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||
// if (proxyClientSettings.isEnabled())
|
||||
// connectProxy(proxyClientSettings);
|
||||
// else
|
||||
ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||
if (proxyClientSettings.isEnabled() && proxyClientSettings.isAllowWebsocket())
|
||||
connectProxy(proxyClientSettings);
|
||||
else
|
||||
connectDefault();
|
||||
}
|
||||
|
||||
@@ -115,15 +115,14 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
||||
}
|
||||
while (proxySettings.hasNext()) {
|
||||
ProxyData proxyData = proxySettings.next();
|
||||
if (!tryProxyConnection(proxySettings, proxyData)) {
|
||||
if (proxySettings.isAutoDiscard())
|
||||
proxySettings.remove();
|
||||
continue;
|
||||
}
|
||||
if (tryProxyConnection(proxySettings, proxyData)) {
|
||||
heartbeatTask.run(webSocketClient, clientSettings.getPingInterval());
|
||||
isConnected = true;
|
||||
break;
|
||||
}
|
||||
if (proxySettings.isAutoDiscard())
|
||||
proxySettings.remove();
|
||||
}
|
||||
if (!isConnected)
|
||||
throw new TikTokLiveException("Failed to connect to the websocket");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user