mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Changes:
`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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user