mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Add direct method to provide sessionId and ttTargetIdc for sending chats from 1 client.
This commit is contained in:
@@ -199,7 +199,12 @@ public class TikTokLiveClient implements LiveClient
|
||||
|
||||
@Override
|
||||
public boolean sendChat(String content) {
|
||||
return httpClient.sendChat(roomInfo, content);
|
||||
return sendChat(content, clientSettings.getSessionId(), clientSettings.getTtTargetIdc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChat(String content, String sessionId, String ttTargetIdc) {
|
||||
return httpClient.sendChat(roomInfo, content, sessionId, ttTargetIdc);
|
||||
}
|
||||
|
||||
public void connectAsync(Consumer<LiveClient> onConnection) {
|
||||
|
||||
@@ -182,23 +182,23 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChat(LiveRoomInfo roomInfo, String content) {
|
||||
public boolean sendChat(LiveRoomInfo roomInfo, String content, String sessionId, String ttTargetIdc) {
|
||||
var proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||
if (proxyClientSettings.isEnabled()) {
|
||||
while (proxyClientSettings.hasNext()) {
|
||||
try {
|
||||
return requestSendChat(roomInfo, content);
|
||||
return requestSendChat(roomInfo, content, sessionId, ttTargetIdc);
|
||||
} catch (TikTokProxyRequestException ignored) {}
|
||||
}
|
||||
}
|
||||
return requestSendChat(roomInfo, content);
|
||||
return requestSendChat(roomInfo, content, sessionId, ttTargetIdc);
|
||||
}
|
||||
|
||||
public boolean requestSendChat(LiveRoomInfo roomInfo, String content) {
|
||||
public boolean requestSendChat(LiveRoomInfo roomInfo, String content, String sessionId, String ttTargetIdc) {
|
||||
JsonObject body = new JsonObject();
|
||||
body.addProperty("content", content);
|
||||
body.addProperty("sessionId", clientSettings.getSessionId());
|
||||
body.addProperty("ttTargetIdc", clientSettings.getTtTargetIdc());
|
||||
body.addProperty("sessionId", sessionId);
|
||||
body.addProperty("ttTargetIdc", ttTargetIdc);
|
||||
body.addProperty("roomId", roomInfo.getRoomId());
|
||||
HttpClientBuilder builder = httpFactory.client(clientSettings.isUseEulerstreamEnterprise() ? TIKTOK_CHAT_ENTERPRISE_URL : TIKTOK_CHAT_URL)
|
||||
.withHeader("Content-Type", "application/json");
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TikTokLiveHttpOfflineClient implements LiveHttpClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChat(LiveRoomInfo roomInfo, String content) {
|
||||
public boolean sendChat(LiveRoomInfo roomInfo, String content, String sessionId, String ttTargetIdc) {
|
||||
// DO NOTHING
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user