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
|
@Setter
|
||||||
public class ProxyClientSettings implements Iterator<ProxyData>, Iterable<ProxyData>
|
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 Rotation rotation = Rotation.CONSECUTIVE;
|
||||||
private final List<ProxyData> proxyList = new ArrayList<>();
|
private final List<ProxyData> proxyList = new ArrayList<>();
|
||||||
private int index;
|
private int index;
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
|||||||
tikTokEventHandler,
|
tikTokEventHandler,
|
||||||
liveClient);
|
liveClient);
|
||||||
|
|
||||||
// ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||||
// if (proxyClientSettings.isEnabled())
|
if (proxyClientSettings.isEnabled() && proxyClientSettings.isAllowWebsocket())
|
||||||
// connectProxy(proxyClientSettings);
|
connectProxy(proxyClientSettings);
|
||||||
// else
|
else
|
||||||
connectDefault();
|
connectDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectDefault() {
|
private void connectDefault() {
|
||||||
@@ -115,15 +115,14 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
|||||||
}
|
}
|
||||||
while (proxySettings.hasNext()) {
|
while (proxySettings.hasNext()) {
|
||||||
ProxyData proxyData = proxySettings.next();
|
ProxyData proxyData = proxySettings.next();
|
||||||
if (!tryProxyConnection(proxySettings, proxyData)) {
|
if (tryProxyConnection(proxySettings, proxyData)) {
|
||||||
if (proxySettings.isAutoDiscard())
|
heartbeatTask.run(webSocketClient, clientSettings.getPingInterval());
|
||||||
proxySettings.remove();
|
isConnected = true;
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
heartbeatTask.run(webSocketClient, clientSettings.getPingInterval());
|
if (proxySettings.isAutoDiscard())
|
||||||
isConnected = true;
|
proxySettings.remove();
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
if (!isConnected)
|
if (!isConnected)
|
||||||
throw new TikTokLiveException("Failed to connect to the websocket");
|
throw new TikTokLiveException("Failed to connect to the websocket");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user