`onWebsocketMessage()` TikTokWebsocketMessageEvent new event that is
   triggered when new ProtocolBuffer message come from TikTok server.
   Should be mainly use for debuging purpose

Bugs:
 - Fixed bug: WebcastSocialMessage was always triggering `TikTokShareEvent` events such as `TikTokLikeEvent`, `TikTokFollowEvent`, `TikTokShareEvent`, `TikTokJoinEvent` was ignored

 - Fixed bug: Websocket was disconnecting when there was no incoming events for the while. Fixed by implementing background loop that pinging TikTok server every few ms.

 - Fixed bug: Disconnect method was not working
This commit is contained in:
JW
2023-09-04 12:05:13 +02:00
parent b059afd621
commit 1aff710523
18 changed files with 279 additions and 38 deletions

View File

@@ -4,13 +4,19 @@ import io.github.jwdeveloper.tiktok.events.messages.*;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import java.io.IOException;
import java.time.Duration;
public class Main {
public static String TEST_TIKTOK_USER = "polonezgarage";
public static String TEST_TIKTOK_USER = "olchik.m1";
public static void main(String[] args) throws IOException {
var client = TikTokLive.newClient(TEST_TIKTOK_USER)
.configure(clientSettings ->
{
clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(5));
clientSettings.setRetryOnConnectionFailure(true);
})
.onConnected(Main::onConnected)
.onDisconnected(Main::onDisconnected)
.onRoomViewerData(Main::onViewerData)
@@ -26,9 +32,13 @@ public class Main {
{
error.getException().printStackTrace();
})
.onEvent((liveClient, event) ->
{
var viewers = liveClient.getRoomInfo().getViewersCount();
})
.buildAndRun();
var viewers = client.getRoomInfo().getViewersCount();
System.in.read();
}