mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Compare commits
3 Commits
1.10.5-Rel
...
1.10.6-Rel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81fd7dc85c | ||
|
|
7e59099793 | ||
|
|
dd2f311539 |
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
|
|||||||
@@ -51,9 +51,17 @@ public interface LiveClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the connection.
|
* Disconnects the connection.
|
||||||
|
* @param type
|
||||||
|
* <p>0 - Normal - Initiates disconnection and returns
|
||||||
|
* <p>1 - Disconnects blocking and returns after closure
|
||||||
|
* <p>2 - Disconnects and kills connection to websocket
|
||||||
|
* <p>Default {@link #disconnect()} is 0
|
||||||
*/
|
*/
|
||||||
void disconnect();
|
void disconnect(int type);
|
||||||
|
|
||||||
|
default void disconnect() {
|
||||||
|
disconnect(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use to manually invoke event
|
* Use to manually invoke event
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ import io.github.jwdeveloper.tiktok.live.LiveClient;
|
|||||||
|
|
||||||
public interface LiveSocketClient {
|
public interface LiveSocketClient {
|
||||||
void start(LiveConnectionData.Response webcastResponse, LiveClient tikTokLiveClient);
|
void start(LiveConnectionData.Response webcastResponse, LiveClient tikTokLiveClient);
|
||||||
void stop();
|
void stop(int type);
|
||||||
boolean isConnected();
|
boolean isConnected();
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -153,9 +153,9 @@ public class TikTokLiveClient implements LiveClient
|
|||||||
tikTokEventHandler.publish(this, new TikTokRoomInfoEvent(roomInfo));
|
tikTokEventHandler.publish(this, new TikTokRoomInfoEvent(roomInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect(int type) {
|
||||||
if (webSocketClient.isConnected())
|
if (webSocketClient.isConnected())
|
||||||
webSocketClient.stop();
|
webSocketClient.stop(type);
|
||||||
if (!roomInfo.hasConnectionState(ConnectionState.DISCONNECTED))
|
if (!roomInfo.hasConnectionState(ConnectionState.DISCONNECTED))
|
||||||
setState(ConnectionState.DISCONNECTED);
|
setState(ConnectionState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
|||||||
.withParam("client", "ttlive-java")
|
.withParam("client", "ttlive-java")
|
||||||
.withParam("room_id", room_id);
|
.withParam("room_id", room_id);
|
||||||
|
|
||||||
|
if (clientSettings.getSessionId() != null) // Allows receiving of all comments and Subscribe Events
|
||||||
|
builder.withParam("session_id", clientSettings.getSessionId());
|
||||||
if (clientSettings.getApiKey() != null)
|
if (clientSettings.getApiKey() != null)
|
||||||
builder.withParam("apiKey", clientSettings.getApiKey());
|
builder.withParam("apiKey", clientSettings.getApiKey());
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import io.github.jwdeveloper.tiktok.data.settings.*;
|
|||||||
import io.github.jwdeveloper.tiktok.exceptions.*;
|
import io.github.jwdeveloper.tiktok.exceptions.*;
|
||||||
import io.github.jwdeveloper.tiktok.live.*;
|
import io.github.jwdeveloper.tiktok.live.*;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
|
import org.java_websocket.framing.CloseFrame;
|
||||||
|
|
||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
@@ -56,18 +57,18 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
|||||||
@Override
|
@Override
|
||||||
public void start(LiveConnectionData.Response connectionData, LiveClient liveClient) {
|
public void start(LiveConnectionData.Response connectionData, LiveClient liveClient) {
|
||||||
if (isConnected())
|
if (isConnected())
|
||||||
stop();
|
stop(0);
|
||||||
|
|
||||||
messageHandler.handle(liveClient, connectionData.getWebcastResponse());
|
messageHandler.handle(liveClient, connectionData.getWebcastResponse());
|
||||||
|
|
||||||
var headers = new HashMap<>(clientSettings.getHttpSettings().getHeaders());
|
var headers = new HashMap<>(clientSettings.getHttpSettings().getHeaders());
|
||||||
headers.put("Cookie", connectionData.getWebsocketCookies());
|
headers.put("Cookie", connectionData.getWebsocketCookies());
|
||||||
webSocketClient = new TikTokWebSocketListener(connectionData.getWebsocketUrl(),
|
webSocketClient = new TikTokWebSocketListener(connectionData.getWebsocketUrl(),
|
||||||
headers,
|
headers,
|
||||||
clientSettings.getHttpSettings().getTimeout().toMillisPart(),
|
clientSettings.getHttpSettings().getTimeout().toMillisPart(),
|
||||||
messageHandler,
|
messageHandler,
|
||||||
tikTokEventHandler,
|
tikTokEventHandler,
|
||||||
liveClient);
|
liveClient);
|
||||||
|
|
||||||
ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
ProxyClientSettings proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||||
if (proxyClientSettings.isEnabled() && proxyClientSettings.isAllowWebsocket())
|
if (proxyClientSettings.isEnabled() && proxyClientSettings.isAllowWebsocket())
|
||||||
@@ -128,9 +129,19 @@ public class TikTokWebSocketClient implements LiveSocketClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop(int type) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
webSocketClient.close();
|
switch (type) {
|
||||||
|
case 1 -> {
|
||||||
|
try {
|
||||||
|
webSocketClient.closeBlocking();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new TikTokLiveException("Failed to stop the websocket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2 -> webSocketClient.closeConnection(CloseFrame.NORMAL, "");
|
||||||
|
default -> webSocketClient.close();
|
||||||
|
}
|
||||||
heartbeatTask.stop();
|
heartbeatTask.stop();
|
||||||
}
|
}
|
||||||
webSocketClient = null;
|
webSocketClient = null;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class TikTokWebSocketOfflineClient implements LiveSocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop(int type) {
|
||||||
if (liveClient != null)
|
if (liveClient != null)
|
||||||
handler.publish(liveClient, new TikTokDisconnectedEvent("Stopping"));
|
handler.publish(liveClient, new TikTokDisconnectedEvent("Stopping"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>extension-recorder</artifactId>
|
<artifactId>extension-recorder</artifactId>
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>API</module>
|
<module>API</module>
|
||||||
<module>Client</module>
|
<module>Client</module>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.10.4-Release</version>
|
<version>1.10.5-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user