mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Removed implements TikTokEventListener from TikTokEventListenerBase
Added current viewers to TikTokRoomInfoEventHandler
This commit is contained in:
@@ -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) {}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
@@ -112,4 +114,4 @@ public class TikTokRoomInfoEventHandler {
|
|||||||
});
|
});
|
||||||
return MappingResult.of(message, List.of(event, roomInfoEvent));
|
return MappingResult.of(message, List.of(event, roomInfoEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user