Removed implements TikTokEventListener from TikTokEventListenerBase

Added current viewers to TikTokRoomInfoEventHandler
This commit is contained in:
kohlerpop1
2024-10-09 18:06:28 -04:00
parent 1b3ee24aea
commit e6211e69c5
2 changed files with 4 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ import io.github.jwdeveloper.tiktok.data.events.social.*;
import io.github.jwdeveloper.tiktok.data.events.websocket.*; import io.github.jwdeveloper.tiktok.data.events.websocket.*;
import io.github.jwdeveloper.tiktok.live.LiveClient; import io.github.jwdeveloper.tiktok.live.LiveClient;
public abstract class TikTokEventListenerBase implements TikTokEventListener public abstract class TikTokEventListenerBase
{ {
public void onUnhandledSocial(LiveClient client, TikTokUnhandledSocialEvent event) {} public void onUnhandledSocial(LiveClient client, TikTokUnhandledSocialEvent event) {}

View File

@@ -58,6 +58,7 @@ public class TikTokRoomInfoEventHandler {
@SneakyThrows @SneakyThrows
public TikTokEvent handleUserRanking(byte[] msg) { public TikTokEvent handleUserRanking(byte[] msg) {
var message = WebcastRoomUserSeqMessage.parseFrom(msg); var message = WebcastRoomUserSeqMessage.parseFrom(msg);
var currentViewers = (int) message.getTotal();
var totalUsers = message.getTotalUser(); var totalUsers = message.getTotalUser();
var userRanking = message.getRanksListList().stream().map(RankingUser::new) var userRanking = message.getRanksListList().stream().map(RankingUser::new)
.sorted((ru1, ru2) -> Integer.compare(ru2.getScore(), ru1.getScore())) .sorted((ru1, ru2) -> Integer.compare(ru2.getScore(), ru1.getScore()))
@@ -65,6 +66,7 @@ public class TikTokRoomInfoEventHandler {
return handleRoomInfo(tikTokRoomInfo -> return handleRoomInfo(tikTokRoomInfo ->
{ {
tikTokRoomInfo.setViewersCount(currentViewers);
tikTokRoomInfo.setTotalViewersCount(totalUsers); tikTokRoomInfo.setTotalViewersCount(totalUsers);
tikTokRoomInfo.updateRanking(userRanking); tikTokRoomInfo.updateRanking(userRanking);
}); });