mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Develop 1.10.8 (#140)
* Add support for TikTokLinkMicBattleItemCard for battle/match power-ups * Switch to an efficient pool of daemon threads instead of thread per websocket and sleeping! * Implement Eulerstream send chat API endpoint! * Add static to fields for single instance to manage all heartbeat threads. Far more efficient than 1 thread each sleeping! * Add global comment to known its a true global singleton!
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import io.github.jwdeveloper.dependance.injector.api.annotations.Inject;
|
||||
import io.github.jwdeveloper.tiktok.common.*;
|
||||
@@ -30,9 +31,10 @@ import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
||||
import io.github.jwdeveloper.tiktok.exceptions.*;
|
||||
import io.github.jwdeveloper.tiktok.http.*;
|
||||
import io.github.jwdeveloper.tiktok.http.mappers.*;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.ProtoMessageFetchResult;
|
||||
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -42,6 +44,7 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
||||
* <a href="https://github-wiki-see.page/m/isaackogan/TikTokLive/wiki/All-About-Signatures">Signing API by Isaac Kogan</a>
|
||||
*/
|
||||
private static final String TIKTOK_SIGN_API = "https://tiktok.eulerstream.com/webcast/fetch";
|
||||
private static final String TIKTOK_CHAT_URL = "https://tiktok.eulerstream.com/webcast/chat";
|
||||
private static final String TIKTOK_URL_WEB = "https://www.tiktok.com/";
|
||||
private static final String TIKTOK_URL_WEBCAST = "https://webcast.tiktok.com/webcast/";
|
||||
public static final String TIKTOK_ROOM_GIFTS_URL = TIKTOK_URL_WEBCAST+"gift/list/";
|
||||
@@ -182,6 +185,33 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChat(LiveRoomInfo roomInfo, String content) {
|
||||
var proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||
if (proxyClientSettings.isEnabled()) {
|
||||
while (proxyClientSettings.hasNext()) {
|
||||
try {
|
||||
return requestSendChat(roomInfo, content);
|
||||
} catch (TikTokProxyRequestException ignored) {}
|
||||
}
|
||||
}
|
||||
return requestSendChat(roomInfo, content);
|
||||
}
|
||||
|
||||
public boolean requestSendChat(LiveRoomInfo roomInfo, String content) {
|
||||
JsonObject body = new JsonObject();
|
||||
body.addProperty("content", content);
|
||||
body.addProperty("sessionId", clientSettings.getSessionId());
|
||||
body.addProperty("ttTargetIdc", clientSettings.getTtTargetIdc());
|
||||
body.addProperty("roomId", roomInfo.getRoomId());
|
||||
var result = httpFactory.client(TIKTOK_CHAT_URL)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(HttpRequest.BodyPublishers.ofString(body.toString()))
|
||||
.build()
|
||||
.toJsonResponse();
|
||||
return result.isSuccess();
|
||||
}
|
||||
|
||||
protected ActionResult<HttpResponse<byte[]>> getStartingPayload(LiveConnectionData.Request request) {
|
||||
var proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
|
||||
if (proxyClientSettings.isEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user