mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Compare commits
24 Commits
1.6.2-Rele
...
1.7.2-Rele
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a66d240bc | ||
|
|
d825803187 | ||
|
|
77c9cd6b52 | ||
|
|
0329d3cfeb | ||
|
|
26659bb37d | ||
|
|
0b9852c4d4 | ||
|
|
31618a16ba | ||
|
|
243791f6b8 | ||
|
|
4f74a0f1b7 | ||
|
|
d1eec34fca | ||
|
|
82196ef8e3 | ||
|
|
8685d96ccf | ||
|
|
69f1d5b5c2 | ||
|
|
6f322b2a46 | ||
|
|
73c4c09ea1 | ||
|
|
95e357af92 | ||
|
|
6b31ec7d80 | ||
|
|
919554bbc8 | ||
|
|
bd0a1f0d01 | ||
|
|
f48479a92c | ||
|
|
68a86f3dbd | ||
|
|
c3a7a27948 | ||
|
|
af52e15a45 | ||
|
|
5577df7c9c |
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ public class TikTokBarrageEvent extends TikTokHeaderEvent {
|
|||||||
private final Picture rightIcon;
|
private final Picture rightIcon;
|
||||||
private final String eventName;
|
private final String eventName;
|
||||||
private final int duration;
|
private final int duration;
|
||||||
|
private final BarrageParam barrageParam;
|
||||||
private BarrageParam barrageParam;
|
|
||||||
|
|
||||||
public TikTokBarrageEvent(WebcastBarrageMessage msg) {
|
public TikTokBarrageEvent(WebcastBarrageMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
@@ -49,6 +48,5 @@ public class TikTokBarrageEvent extends TikTokHeaderEvent {
|
|||||||
rightIcon = Picture.map(msg.getRightIcon());
|
rightIcon = Picture.map(msg.getRightIcon());
|
||||||
duration = msg.getDuration();
|
duration = msg.getDuration();
|
||||||
barrageParam = BarrageParam.map(msg);
|
barrageParam = BarrageParam.map(msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@ public class TikTokCaptionEvent extends TikTokHeaderEvent {
|
|||||||
String text;
|
String text;
|
||||||
|
|
||||||
public TikTokCaptionEvent(WebcastCaptionMessage msg) {
|
public TikTokCaptionEvent(WebcastCaptionMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
captionTimeStamp = msg.getTimeStamp();
|
captionTimeStamp = msg.getTimeStamp();
|
||||||
iSOLanguage = msg.getCaptionData().getLanguage();
|
iSOLanguage = msg.getCaptionData().getLanguage();
|
||||||
text = msg.getCaptionData().getText();
|
text = msg.getCaptionData().getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ import java.util.List;
|
|||||||
public class TikTokCommentEvent extends TikTokHeaderEvent {
|
public class TikTokCommentEvent extends TikTokHeaderEvent {
|
||||||
private final User user;
|
private final User user;
|
||||||
private final String text;
|
private final String text;
|
||||||
private final String getUserLanguage;
|
private final String userLanguage;
|
||||||
private final User mentionedUser;
|
private final User mentionedUser;
|
||||||
private final List<Picture> pictures;
|
private final List<Picture> pictures;
|
||||||
private final boolean visibleToSender;
|
private final boolean visibleToSender;
|
||||||
@@ -50,7 +50,7 @@ public class TikTokCommentEvent extends TikTokHeaderEvent {
|
|||||||
user = User.map(msg.getUser(), msg.getUserIdentity());
|
user = User.map(msg.getUser(), msg.getUserIdentity());
|
||||||
text = msg.getContent();
|
text = msg.getContent();
|
||||||
visibleToSender = msg.getVisibleToSender();
|
visibleToSender = msg.getVisibleToSender();
|
||||||
getUserLanguage = msg.getContentLanguage();
|
userLanguage = msg.getContentLanguage();
|
||||||
mentionedUser = User.map(msg.getAtUser());
|
mentionedUser = User.map(msg.getAtUser());
|
||||||
pictures = msg.getEmotesListList().stream().map(e -> Picture.map(e.getEmote().getImage())).toList();
|
pictures = msg.getEmotesListList().stream().map(e -> Picture.map(e.getEmote().getImage())).toList();
|
||||||
}
|
}
|
||||||
@@ -66,4 +66,4 @@ public class TikTokCommentEvent extends TikTokHeaderEvent {
|
|||||||
builder.setContent(message);
|
builder.setContent(message);
|
||||||
return new TikTokCommentEvent(builder.build());
|
return new TikTokCommentEvent(builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,14 +30,10 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokDetectEvent extends TikTokHeaderEvent {
|
public class TikTokDetectEvent extends TikTokHeaderEvent {
|
||||||
String language;
|
private final String language;
|
||||||
|
|
||||||
|
public TikTokDetectEvent(WebcastMsgDetectMessage msg) {
|
||||||
public TikTokDetectEvent(WebcastMsgDetectMessage msg) {
|
super(msg.getCommon());
|
||||||
super(msg.getCommon());
|
language = msg.getFromRegion();
|
||||||
language = msg.getFromRegion();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -30,9 +30,11 @@ import lombok.Getter;
|
|||||||
* Triggered when the connection gets disconnected. In that case you can call connect() again to have a reconnect logic.
|
* Triggered when the connection gets disconnected. In that case you can call connect() again to have a reconnect logic.
|
||||||
* Note that you should wait a little bit before attempting a reconnect to to avoid being rate-limited.
|
* Note that you should wait a little bit before attempting a reconnect to to avoid being rate-limited.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Control)
|
@EventMeta(eventType = EventType.Control)
|
||||||
public class TikTokDisconnectedEvent extends TikTokLiveClientEvent {
|
public class TikTokDisconnectedEvent extends TikTokLiveClientEvent {
|
||||||
@Getter private final String reason;
|
private final String reason;
|
||||||
|
|
||||||
public TikTokDisconnectedEvent(String reason) {
|
public TikTokDisconnectedEvent(String reason) {
|
||||||
this.reason = reason.isBlank() ? "None" : reason;
|
this.reason = reason.isBlank() ? "None" : reason;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ import lombok.Value;
|
|||||||
@Value
|
@Value
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokEnvelopeEvent extends TikTokHeaderEvent {
|
public class TikTokEnvelopeEvent extends TikTokHeaderEvent {
|
||||||
User user;
|
User user;
|
||||||
public TikTokEnvelopeEvent(WebcastEnvelopeMessage msg) {
|
public TikTokEnvelopeEvent(WebcastEnvelopeMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
user = User.map(msg.getEnvelopeInfo());
|
user = User.map(msg.getEnvelopeInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,9 +34,10 @@ import java.util.List;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokIMDeleteEvent extends TikTokHeaderEvent {
|
public class TikTokIMDeleteEvent extends TikTokHeaderEvent {
|
||||||
|
|
||||||
List<Long> userIds;
|
private final List<Long> msgIds, userIds;
|
||||||
public TikTokIMDeleteEvent(WebcastImDeleteMessage msg) {
|
public TikTokIMDeleteEvent(WebcastImDeleteMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
|
this.msgIds = msg.getDeleteMsgIdsListList();
|
||||||
this.userIds = msg.getDeleteUserIdsListList();
|
this.userIds = msg.getDeleteUserIdsListList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,10 +31,10 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokInRoomBannerEvent extends TikTokHeaderEvent {
|
public class TikTokInRoomBannerEvent extends TikTokHeaderEvent {
|
||||||
private final String json;
|
private final String json;
|
||||||
|
|
||||||
public TikTokInRoomBannerEvent(WebcastInRoomBannerMessage msg) {
|
public TikTokInRoomBannerEvent(WebcastInRoomBannerMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getHeader());
|
||||||
json = msg.getJson();
|
json = msg.getJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,11 +33,7 @@ import lombok.Getter;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkLayerEvent extends TikTokHeaderEvent {
|
public class TikTokLinkLayerEvent extends TikTokHeaderEvent {
|
||||||
|
|
||||||
|
|
||||||
public TikTokLinkLayerEvent(WebcastLinkLayerMessage msg) {
|
public TikTokLinkLayerEvent(WebcastLinkLayerMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
@@ -32,10 +32,8 @@ import lombok.Getter;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkMicMethodEvent extends TikTokHeaderEvent {
|
public class TikTokLinkMicMethodEvent extends TikTokHeaderEvent {
|
||||||
|
|
||||||
public TikTokLinkMicMethodEvent(WebcastLinkMicMethod msg) {
|
public TikTokLinkMicMethodEvent(WebcastLinkMicMethod msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
@@ -32,15 +32,14 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRankTextEvent extends TikTokHeaderEvent {
|
public class TikTokRankTextEvent extends TikTokHeaderEvent {
|
||||||
private final String eventType;
|
private final String eventType;
|
||||||
|
|
||||||
private final String label;
|
private final String label;
|
||||||
|
|
||||||
public TikTokRankTextEvent(WebcastRankTextMessage msg) {
|
public TikTokRankTextEvent(WebcastRankTextMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
var text = Text.map(msg.getSelfGetBadgeMsg());
|
var text = Text.map(msg.getSelfGetBadgeMsg());
|
||||||
label = text.getPattern();
|
label = text.getPattern();
|
||||||
eventType = text.getKey();
|
eventType = text.getKey();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -33,13 +33,11 @@ import lombok.Getter;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRankUpdateEvent extends TikTokHeaderEvent {
|
public class TikTokRankUpdateEvent extends TikTokHeaderEvent {
|
||||||
|
|
||||||
public TikTokRankUpdateEvent(WebcastHourlyRankMessage msg) {
|
public TikTokRankUpdateEvent(WebcastHourlyRankMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public TikTokRankUpdateEvent(WebcastRankUpdateMessage msg) {
|
||||||
|
super(msg.getCommon());
|
||||||
public TikTokRankUpdateEvent(WebcastRankUpdateMessage msg) {
|
}
|
||||||
super(msg.getCommon());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -32,25 +32,24 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokShopEvent extends TikTokHeaderEvent {
|
public class TikTokShopEvent extends TikTokHeaderEvent {
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
private final String price;
|
private final String price;
|
||||||
|
|
||||||
private final Picture picture;
|
private final Picture picture;
|
||||||
|
|
||||||
private final String shopUrl;
|
private final String shopUrl;
|
||||||
|
|
||||||
private final String shopName;
|
private final String shopName;
|
||||||
|
|
||||||
//Not working
|
//Not working
|
||||||
public TikTokShopEvent(WebcastOecLiveShoppingMessage msg) {
|
public TikTokShopEvent(WebcastOecLiveShoppingMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
var data = msg.getShopData();
|
var data = msg.getShopData();
|
||||||
title = data.getTitle();
|
title = data.getTitle();
|
||||||
price = data.getPriceString();
|
price = data.getPriceString();
|
||||||
picture = new Picture(data.getImageUrl());
|
picture = new Picture(data.getImageUrl());
|
||||||
shopUrl = data.getShopUrl();
|
shopUrl = data.getShopUrl();
|
||||||
shopName = data.getShopName();
|
shopName = data.getShopName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -30,12 +30,13 @@ import lombok.*;
|
|||||||
/**
|
/**
|
||||||
* Triggered before the connection is established.
|
* Triggered before the connection is established.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Control)
|
@EventMeta(eventType = EventType.Control)
|
||||||
public class TikTokPreConnectionEvent extends TikTokLiveClientEvent
|
public class TikTokPreConnectionEvent extends TikTokLiveClientEvent
|
||||||
{
|
{
|
||||||
@Getter private final LiveUserData.Response userData;
|
private final LiveUserData.Response userData;
|
||||||
@Getter private final LiveData.Response roomData;
|
private final LiveData.Response roomData;
|
||||||
@Getter @Setter boolean cancelConnection = false;
|
@Setter boolean cancelConnection = false;
|
||||||
|
|
||||||
public TikTokPreConnectionEvent(LiveUserData.Response userData, LiveData.Response liveData) {
|
public TikTokPreConnectionEvent(LiveUserData.Response userData, LiveData.Response liveData) {
|
||||||
this.userData = userData;
|
this.userData = userData;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkAcceptNoticeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long fromUserId, fromRoomId, toUserId;
|
||||||
|
|
||||||
|
public TikTokLinkAcceptNoticeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasAcceptNoticeContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Accept Notice Content!");
|
||||||
|
|
||||||
|
var content = msg.getAcceptNoticeContent();
|
||||||
|
this.fromUserId = content.getFromUserId();
|
||||||
|
this.fromRoomId = content.getFromRoomId();
|
||||||
|
this.toUserId = content.getToUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,18 +20,17 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.models;
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
import lombok.Value;
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
@Value
|
@Getter
|
||||||
public class EnumValue
|
@EventMeta(eventType = EventType.Message)
|
||||||
{
|
public class TikTokLinkApplyEvent extends TikTokLinkEvent {
|
||||||
public int value;
|
|
||||||
public String name;
|
|
||||||
|
|
||||||
public static EnumValue Map(Enum<?> _enum)
|
public TikTokLinkApplyEvent(WebcastLinkMessage msg) {
|
||||||
{
|
super(msg);
|
||||||
return new EnumValue(_enum.ordinal() ,_enum.name());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkCancelEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long fromUserId, toUserId, cancelType, actionId;
|
||||||
|
|
||||||
|
public TikTokLinkCancelEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasCancelContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Cancel Content!");
|
||||||
|
|
||||||
|
var content = msg.getCancelContent();
|
||||||
|
this.fromUserId = content.getFromUserId();
|
||||||
|
this.toUserId = content.getToUserId();
|
||||||
|
this.cancelType = content.getCancelType();
|
||||||
|
this.actionId = content.getActionId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkCloseEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
public TikTokLinkCloseEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
// if (!msg.hasCloseContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Close Content!");
|
||||||
|
// Proto Empty
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkCohostListChangeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
public TikTokLinkCohostListChangeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
// if (!msg.hasCohostListChangeContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Cohost List Change Content!");
|
||||||
|
// Proto Empty
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkCreateEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long hostId, roomId, linkType;
|
||||||
|
public TikTokLinkCreateEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasCreateContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Create Content!");
|
||||||
|
|
||||||
|
var content = msg.getCreateContent();
|
||||||
|
this.hostId = content.getOwnerId();
|
||||||
|
this.roomId = content.getOwnerRoomId();
|
||||||
|
this.linkType = content.getLinkType();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.users.ListUser;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkEnterEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final List<ListUser> listUsers;
|
||||||
|
private final int anchorMultiLiveEnum;
|
||||||
|
|
||||||
|
public TikTokLinkEnterEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasEnterContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Enter Content!");
|
||||||
|
|
||||||
|
var content = msg.getEnterContent();
|
||||||
|
this.listUsers = content.getLinkedUsersListList().stream().map(ListUser::map).toList();
|
||||||
|
this.anchorMultiLiveEnum = content.getAnchorMultiLiveEnum();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,24 +20,24 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.events;
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkEvent extends TikTokHeaderEvent {
|
public class TikTokLinkEvent extends TikTokHeaderEvent {
|
||||||
|
|
||||||
|
private final String extra, transferExtra;
|
||||||
|
private final long expireTimestamp;
|
||||||
|
|
||||||
public TikTokLinkEvent(WebcastLinkMessage msg) {
|
public TikTokLinkEvent(WebcastLinkMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
|
this.extra = msg.getExtra();
|
||||||
|
this.expireTimestamp = msg.getExpireTimestamp();
|
||||||
|
this.transferExtra = msg.getTransferExtra();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkInviteEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long roomId;
|
||||||
|
private final User inviter;
|
||||||
|
|
||||||
|
public TikTokLinkInviteEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasInviteContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Invite Content!");
|
||||||
|
|
||||||
|
var content = msg.getInviteContent();
|
||||||
|
this.roomId = content.getFromRoomId();
|
||||||
|
this.inviter = User.map(content.getFromUser());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkKickOutEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long fromUserId;
|
||||||
|
private final KickOutReason kickOutReason;
|
||||||
|
|
||||||
|
public TikTokLinkKickOutEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasKickOutContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Kick Out Content!");
|
||||||
|
|
||||||
|
var content = msg.getKickOutContent();
|
||||||
|
this.fromUserId = content.getFromUserId();
|
||||||
|
this.kickOutReason = KickOutReason.values()[content.getKickoutReasonValue()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum KickOutReason {
|
||||||
|
KICKOUT_REASON_UNKNOWN,
|
||||||
|
KICKOUT_REASON_FIRST_FRAME_TIMEOUT,
|
||||||
|
KICKOUT_REASON_BY_HOST,
|
||||||
|
KICKOUT_REASON_RTC_LOST_CONNECTION,
|
||||||
|
KICKOUT_REASON_BY_PUNISH,
|
||||||
|
KICKOUT_REASON_BY_ADMIN,
|
||||||
|
KICKOUT_REASON_HOST_REMOVE_ALL_GUESTS
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkLeaveEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long userId, sendLeaveUid, leaveReason;
|
||||||
|
private final String linkmicIdStr;
|
||||||
|
|
||||||
|
public TikTokLinkLeaveEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasLeaveContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Leave Content!");
|
||||||
|
|
||||||
|
var content = msg.getLeaveContent();
|
||||||
|
this.userId = content.getUserId();
|
||||||
|
this.linkmicIdStr = content.getLinkmicIdStr();
|
||||||
|
this.sendLeaveUid = content.getSendLeaveUid();
|
||||||
|
this.leaveReason = content.getLeaveReason();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkLinkedListChangeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
public TikTokLinkLinkedListChangeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
// if (!msg.hasLinkedListChangeContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Linked List Change Content!");
|
||||||
|
// Proto Empty
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.users.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkListChangeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final List<ListUser> linkedUsers, appliedUsers, connectingUsers;
|
||||||
|
|
||||||
|
public TikTokLinkListChangeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasListChangeContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with List Change Content!");
|
||||||
|
|
||||||
|
var content = msg.getListChangeContent();
|
||||||
|
this.linkedUsers = content.getLinkedUsersList().stream().map(ListUser::map).toList();
|
||||||
|
this.appliedUsers = content.getAppliedUsersList().stream().map(ListUser::map).toList();
|
||||||
|
this.connectingUsers = content.getConnectingUsersList().stream().map(ListUser::map).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkMediaChangeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long op, toUserId, anchorId, roomId, changeScene;
|
||||||
|
|
||||||
|
public TikTokLinkMediaChangeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasMediaChangeContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Media Change Content!");
|
||||||
|
|
||||||
|
var content = msg.getMediaChangeContent();
|
||||||
|
this.op = content.getOp();
|
||||||
|
this.toUserId = content.getToUserId();
|
||||||
|
this.anchorId = content.getAnchorId();
|
||||||
|
this.roomId = content.getRoomId();
|
||||||
|
this.changeScene = content.getChangeScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,24 +20,20 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.events;
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
import lombok.Getter;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
@Getter
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class CustomEvent extends TikTokHeaderEvent {
|
public class TikTokLinkMicIdxUpdateEvent extends TikTokLinkEvent {
|
||||||
private final User user;
|
|
||||||
private final String title;
|
|
||||||
|
|
||||||
public CustomEvent(User user, String title) {
|
public TikTokLinkMicIdxUpdateEvent(WebcastLinkMessage msg) {
|
||||||
this.user = user;
|
super(msg);
|
||||||
this.title = title;
|
// if (!msg.hasMicIdxUpdateContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Mic Idx Update Content!");
|
||||||
|
// Proto Empty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkMuteEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long userId, status;
|
||||||
|
|
||||||
|
public TikTokLinkMuteEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasMuteContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Mute Content!");
|
||||||
|
|
||||||
|
var content = msg.getMuteContent();
|
||||||
|
this.userId = content.getUserId();
|
||||||
|
this.status = content.getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkRandomMatchEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final User user;
|
||||||
|
private final long roomId, inviteType, innerChannelId;
|
||||||
|
private final String matchId;
|
||||||
|
|
||||||
|
public TikTokLinkRandomMatchEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasRandomMatchContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Random Match Content!");
|
||||||
|
|
||||||
|
var content = msg.getRandomMatchContent();
|
||||||
|
this.user = User.map(content.getUser());
|
||||||
|
this.roomId = content.getRoomId();
|
||||||
|
this.inviteType = content.getInviteType();
|
||||||
|
this.matchId = content.getMatchId();
|
||||||
|
this.innerChannelId = content.getInnerChannelId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkReplyEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long roomId;
|
||||||
|
private final User fromUser, toUser;
|
||||||
|
|
||||||
|
public TikTokLinkReplyEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasReplyContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Reply Content!");
|
||||||
|
|
||||||
|
var content = msg.getReplyContent();
|
||||||
|
this.roomId = content.getFromRoomId();
|
||||||
|
this.fromUser = User.map(content.getFromUser());
|
||||||
|
this.toUser = User.map(content.getToUser());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkSysKickOutEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long userId;
|
||||||
|
private final String linkmicIdStr;
|
||||||
|
|
||||||
|
public TikTokLinkSysKickOutEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasSysKickOutContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Sys Kick Out Content!");
|
||||||
|
|
||||||
|
var content = msg.getSysKickOutContent();
|
||||||
|
this.userId = content.getUserId();
|
||||||
|
this.linkmicIdStr = content.getLinkmicIdStr();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkUpdateUserEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long fromUserId, toUserId;
|
||||||
|
|
||||||
|
public TikTokLinkUpdateUserEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasUpdateUserContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with Update User Content!");
|
||||||
|
|
||||||
|
var content = msg.getUpdateUserContent();
|
||||||
|
this.fromUserId = content.getFromUserId();
|
||||||
|
this.toUserId = content.getToUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkUpdateUserSettingEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
public TikTokLinkUpdateUserSettingEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
// if (!msg.hasUpdateUserSettingContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Update User Setting Content!");
|
||||||
|
// Proto Empty
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.models.Text;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkUserToastEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
private final long userId, roomId;
|
||||||
|
private final Text displayText;
|
||||||
|
|
||||||
|
public TikTokLinkUserToastEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
if (!msg.hasUserToastContent())
|
||||||
|
throw new IllegalArgumentException("Expected WebcastLinkMessage with User Toast Content!");
|
||||||
|
|
||||||
|
var content = msg.getUserToastContent();
|
||||||
|
this.userId = content.getUserId();
|
||||||
|
this.roomId = content.getRoomId();
|
||||||
|
this.displayText = Text.map(content.getDisplayText());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok.data.events.link;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EventMeta(eventType = EventType.Message)
|
||||||
|
public class TikTokLinkWaitListChangeEvent extends TikTokLinkEvent {
|
||||||
|
|
||||||
|
public TikTokLinkWaitListChangeEvent(WebcastLinkMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
// if (!msg.hasWaitingListChangeContent())
|
||||||
|
// throw new IllegalArgumentException("Expected WebcastLinkMessage with Waiting List Change Content!");
|
||||||
|
// Proto Empty
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
|
Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@@ -39,4 +39,4 @@ Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
|
|||||||
public class TikTokRoomInfoEvent extends TikTokEvent
|
public class TikTokRoomInfoEvent extends TikTokEvent
|
||||||
{
|
{
|
||||||
LiveRoomInfo roomInfo;
|
LiveRoomInfo roomInfo;
|
||||||
}
|
}
|
||||||
@@ -33,15 +33,13 @@ import lombok.Getter;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRoomPinEvent extends TikTokHeaderEvent
|
public class TikTokRoomPinEvent extends TikTokHeaderEvent
|
||||||
{
|
{
|
||||||
|
private final TikTokCommentEvent pinnedMessage;
|
||||||
|
private final long timestamp;
|
||||||
|
|
||||||
private TikTokCommentEvent pinnedMessage;
|
public TikTokRoomPinEvent(WebcastRoomPinMessage msg, TikTokCommentEvent commentEvent)
|
||||||
private long timestamp;
|
{
|
||||||
|
super(msg.getCommon());
|
||||||
public TikTokRoomPinEvent(WebcastRoomPinMessage msg, TikTokCommentEvent commentEvent)
|
this.timestamp = msg.getTimestamp();
|
||||||
{
|
this.pinnedMessage = commentEvent;
|
||||||
super(msg.getCommon());
|
}
|
||||||
this.timestamp = msg.getTimestamp();
|
}
|
||||||
this.pinnedMessage = commentEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -24,10 +24,8 @@ package io.github.jwdeveloper.tiktok.data.events.social;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
@@ -38,21 +36,21 @@ import lombok.Value;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokFollowEvent extends TikTokHeaderEvent
|
public class TikTokFollowEvent extends TikTokHeaderEvent
|
||||||
{
|
{
|
||||||
User user;
|
User user;
|
||||||
int totalFollowers;
|
int totalFollowers;
|
||||||
|
|
||||||
public TikTokFollowEvent(WebcastSocialMessage msg) {
|
public TikTokFollowEvent(WebcastSocialMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
user = User.map(msg.getUser());
|
user = User.map(msg.getUser());
|
||||||
totalFollowers = msg.getFollowCount();
|
totalFollowers = msg.getFollowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TikTokFollowEvent of(String userName)
|
public static TikTokFollowEvent of(String userName)
|
||||||
{
|
{
|
||||||
return new TikTokFollowEvent(WebcastSocialMessage.newBuilder()
|
return new TikTokFollowEvent(WebcastSocialMessage.newBuilder()
|
||||||
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
.setNickname(userName)
|
.setNickname(userName)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,19 +35,18 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokShareEvent extends TikTokHeaderEvent {
|
public class TikTokShareEvent extends TikTokHeaderEvent {
|
||||||
private final User user;
|
private final User user;
|
||||||
private final int totalShares;
|
private final int totalShares;
|
||||||
|
|
||||||
public TikTokShareEvent(WebcastSocialMessage msg, Integer amount) {
|
public TikTokShareEvent(WebcastSocialMessage msg, Integer amount) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
user = User.map(msg.getUser());
|
user = User.map(msg.getUser());
|
||||||
this.totalShares = amount;
|
this.totalShares = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokShareEvent(WebcastSocialMessage msg) {
|
public TikTokShareEvent(WebcastSocialMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
user = User.map(msg.getUser());
|
user = User.map(msg.getUser());
|
||||||
totalShares = 1;
|
totalShares = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.models.gifts;
|
package io.github.jwdeveloper.tiktok.data.models.gifts;
|
||||||
|
|
||||||
//TODO it should be called GiftComboStateType
|
|
||||||
public enum GiftComboStateType {
|
public enum GiftComboStateType {
|
||||||
Finished,
|
Finished,
|
||||||
Begin,
|
Begin,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
|||||||
|
package io.github.jwdeveloper.tiktok.data.models.users;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class ListUser
|
||||||
|
{
|
||||||
|
private final User user;
|
||||||
|
private final LinkType linkType;
|
||||||
|
private final long linkMicId, linkStatus, modifyTime, linkerId;
|
||||||
|
private final int userPosition, silenceStatus, roleType;
|
||||||
|
|
||||||
|
public ListUser(io.github.jwdeveloper.tiktok.messages.data.ListUser listUser) {
|
||||||
|
this.user = User.map(listUser.getUser());
|
||||||
|
this.linkMicId = listUser.getLinkmicId();
|
||||||
|
this.linkStatus = listUser.getLinkStatus();
|
||||||
|
this.linkType = LinkType.values()[listUser.getLinkTypeValue()];
|
||||||
|
this.userPosition = listUser.getUserPosition();
|
||||||
|
this.silenceStatus = listUser.getSilenceStatus();
|
||||||
|
this.modifyTime = listUser.getModifyTime();
|
||||||
|
this.linkerId = listUser.getLinkerId();
|
||||||
|
this.roleType = listUser.getRoleType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListUser map(io.github.jwdeveloper.tiktok.messages.data.ListUser listUser) {
|
||||||
|
return new ListUser(listUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LinkType {
|
||||||
|
UNKNOWN,
|
||||||
|
AUDIO,
|
||||||
|
VIDEO
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,20 +23,12 @@
|
|||||||
package io.github.jwdeveloper.tiktok.data.requests;
|
package io.github.jwdeveloper.tiktok.data.requests;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
|
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GiftsData
|
public class GiftsData
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
public final class Request
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static final class Response
|
public static final class Response
|
||||||
@@ -44,5 +36,4 @@ public class GiftsData
|
|||||||
private String json;
|
private String json;
|
||||||
private List<Gift> gifts;
|
private List<Gift> gifts;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -34,30 +34,24 @@ import java.util.TreeMap;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class HttpClientSettings {
|
public class HttpClientSettings {
|
||||||
|
|
||||||
@Getter
|
private final Map<String, Object> params;
|
||||||
final Map<String, Object> params;
|
|
||||||
|
|
||||||
@Getter
|
private final Map<String, String> headers;
|
||||||
final Map<String, String> headers;
|
|
||||||
|
|
||||||
@Getter
|
private final Map<String, String> cookies;
|
||||||
final Map<String, String> cookies;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
ProxyClientSettings proxyClientSettings;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
Consumer<HttpClient.Builder> onClientCreating;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
Consumer<HttpRequest.Builder> onRequestCreating;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
private ProxyClientSettings proxyClientSettings;
|
||||||
Duration timeout;
|
|
||||||
|
private Consumer<HttpClient.Builder> onClientCreating;
|
||||||
|
|
||||||
|
private Consumer<HttpRequest.Builder> onRequestCreating;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Duration timeout;
|
||||||
|
|
||||||
public HttpClientSettings() {
|
public HttpClientSettings() {
|
||||||
this.params = new TreeMap<>();
|
this.params = new TreeMap<>();
|
||||||
@@ -65,10 +59,8 @@ public class HttpClientSettings {
|
|||||||
this.cookies = new HashMap<>();
|
this.cookies = new HashMap<>();
|
||||||
this.timeout = Duration.ofSeconds(2);
|
this.timeout = Duration.ofSeconds(2);
|
||||||
this.proxyClientSettings = new ProxyClientSettings();
|
this.proxyClientSettings = new ProxyClientSettings();
|
||||||
this.onClientCreating = (x) -> {
|
this.onClientCreating = (x) -> {};
|
||||||
};
|
this.onRequestCreating = (x) -> {};
|
||||||
this.onRequestCreating = (x) -> {
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -178,6 +178,4 @@ public class LiveClientSettings {
|
|||||||
headers.put("Accept-Language", "en-US,en; q=0.9");
|
headers.put("Accept-Language", "en-US,en; q=0.9");
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,53 +22,52 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.listener;
|
package io.github.jwdeveloper.tiktok.listener;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* ListenersManager
|
||||||
* @see ListenersManager
|
* <p>
|
||||||
*
|
|
||||||
* TikTokEventListener is an alternative way of handing TikTok events.
|
* TikTokEventListener is an alternative way of handing TikTok events.
|
||||||
|
* <p>
|
||||||
|
* {@code TikTokLive.newClient("someuser").addListener(listener);}
|
||||||
|
* <p>
|
||||||
|
* After registertion, all listeners are kept in Listener manager - {@link LiveClient#getListenersManager()}
|
||||||
|
* <p>
|
||||||
|
* Method in TikTokEventListener should meet requirements below to be detected
|
||||||
|
* <p>- @TikTokEventObserver annotation
|
||||||
|
* <p>- 2 parameters of (LiveClient, Class extending TikTokEvent)
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* public static class CustomListener implements TikTokEventListener
|
||||||
|
* {
|
||||||
|
* @TikTokEventObserver
|
||||||
|
* public void onError(LiveClient liveClient, TikTokErrorEvent event)
|
||||||
|
* {
|
||||||
|
* System.out.println(event.getException().getMessage());
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* TikTokLive.newClient("someuser").addListener(listener)
|
* @TikTokEventObserver
|
||||||
|
* public void onCommentMessage(LiveClient liveClient, TikTokCommentEvent event)
|
||||||
|
* {
|
||||||
|
* System.out.println(event.getText());
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* After registertion all listeners are kept in Listener manager
|
* @TikTokEventObserver
|
||||||
* that could be obtained by client.getListenerManager();
|
* public void onGiftMessage(LiveClient liveClient, TikTokGiftMessageEvent event)
|
||||||
*
|
* {
|
||||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
* System.out.println(event.getGift().getDescription());
|
||||||
* - must have @TikTokEventHandler annotation
|
* }
|
||||||
* - must have 2 parameters
|
|
||||||
* - first parameter must be LiveClient
|
|
||||||
* - second must be class that extending TikTokEvent
|
|
||||||
*
|
|
||||||
* public static class CustomListener implements TikTokEventListener
|
|
||||||
* {
|
|
||||||
* @TikTokEventHandler
|
|
||||||
* public void onError(LiveClient liveClient, TikTokErrorEvent event)
|
|
||||||
* {
|
|
||||||
* System.out.println(event.getException().getMessage());
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @TikTokEventHandler
|
|
||||||
* public void onCommentMessage(LiveClient liveClient, TikTokCommentEvent event)
|
|
||||||
* {
|
|
||||||
* System.out.println(event.getText());
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @TikTokEventHandler
|
|
||||||
* public void onGiftMessage(LiveClient liveClient, TikTokGiftMessageEvent event)
|
|
||||||
* {
|
|
||||||
* System.out.println(event.getGift().getDescription());
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @TikTokEventHandler
|
|
||||||
* public void onAnyEvent(LiveClient liveClient, TikTokEvent event)
|
|
||||||
* {
|
|
||||||
* System.out.println(event.getClass().getSimpleName());
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
*
|
||||||
|
* @TikTokEventObserver
|
||||||
|
* public void onAnyEvent(LiveClient liveClient, TikTokEvent event)
|
||||||
|
* {
|
||||||
|
* System.out.println(event.getClass().getSimpleName());
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public interface TikTokEventListener
|
public interface TikTokEventListener
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package io.github.jwdeveloper.tiktok.listener;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.control.TikTokPreConnectionEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.gift.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.link.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.room.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.social.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.websocket.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
|
|
||||||
|
public abstract class TikTokEventListenerBase implements TikTokEventListener
|
||||||
|
{
|
||||||
|
public void onUnhandledSocial(LiveClient client, TikTokUnhandledSocialEvent event) {}
|
||||||
|
|
||||||
|
public void onChest(LiveClient client, TikTokChestEvent event) {}
|
||||||
|
|
||||||
|
public void onLinkMicFanTicket(LiveClient client, TikTokLinkMicFanTicketEvent event) {}
|
||||||
|
|
||||||
|
public void onEnvelope(LiveClient client, TikTokEnvelopeEvent event) {}
|
||||||
|
|
||||||
|
public void onShop(LiveClient client, TikTokShopEvent event) {}
|
||||||
|
|
||||||
|
public void onDetect(LiveClient client, TikTokDetectEvent event) {}
|
||||||
|
|
||||||
|
public void onLinkLayer(LiveClient client, TikTokLinkLayerEvent event) {}
|
||||||
|
|
||||||
|
public void onConnected(LiveClient client, TikTokConnectedEvent event) {}
|
||||||
|
|
||||||
|
public void onPreConnection(LiveClient client, TikTokPreConnectionEvent event) {}
|
||||||
|
|
||||||
|
public void onCaption(LiveClient client, TikTokCaptionEvent event) {}
|
||||||
|
|
||||||
|
public void onQuestion(LiveClient client, TikTokQuestionEvent event) {}
|
||||||
|
|
||||||
|
public void onRoomPin(LiveClient client, TikTokRoomPinEvent event) {}
|
||||||
|
|
||||||
|
public void onRoomInfo(LiveClient client, TikTokRoomInfoEvent event) {}
|
||||||
|
|
||||||
|
public void onLivePaused(LiveClient client, TikTokLivePausedEvent event) {}
|
||||||
|
|
||||||
|
public void onLiveUnpaused(LiveClient client, TikTokLiveUnpausedEvent event) {}
|
||||||
|
|
||||||
|
public void onLike(LiveClient client, TikTokLikeEvent event) {}
|
||||||
|
|
||||||
|
public void onLink(LiveClient client, TikTokLinkEvent event) {}
|
||||||
|
public void onLinkInvite(LiveClient client, TikTokLinkInviteEvent event) {}
|
||||||
|
public void onLinkReply(LiveClient client, TikTokLinkReplyEvent event) {}
|
||||||
|
public void onLinkCreate(LiveClient client, TikTokLinkCreateEvent event) {}
|
||||||
|
public void onLinkClose(LiveClient client, TikTokLinkCloseEvent event) {}
|
||||||
|
public void onLinkEnter(LiveClient client, TikTokLinkEnterEvent event) {}
|
||||||
|
public void onLinkLeave(LiveClient client, TikTokLinkLeaveEvent event) {}
|
||||||
|
public void onLinkCancel(LiveClient client, TikTokLinkCancelEvent event) {}
|
||||||
|
public void onLinkKickOut(LiveClient client, TikTokLinkKickOutEvent event) {}
|
||||||
|
public void onLinkLinkedListChange(LiveClient client, TikTokLinkLinkedListChangeEvent event) {}
|
||||||
|
public void onLinkUpdateUser(LiveClient client, TikTokLinkUpdateUserEvent event) {}
|
||||||
|
public void onLinkWaitListChange(LiveClient client, TikTokLinkWaitListChangeEvent event) {}
|
||||||
|
public void onLinkMute(LiveClient client, TikTokLinkMuteEvent event) {}
|
||||||
|
public void onLinkRandomMatch(LiveClient client, TikTokLinkRandomMatchEvent event) {}
|
||||||
|
public void onLinkUpdateUserSettings(LiveClient client, TikTokLinkUpdateUserSettingEvent event) {}
|
||||||
|
public void onLinkMicIdxUpdate(LiveClient client, TikTokLinkMicIdxUpdateEvent event) {}
|
||||||
|
public void onLinkListChange(LiveClient client, TikTokLinkListChangeEvent event) {}
|
||||||
|
public void onLinkCohostListChange(LiveClient client, TikTokLinkCohostListChangeEvent event) {}
|
||||||
|
public void onLinkMediaChange(LiveClient client, TikTokLinkMediaChangeEvent event) {}
|
||||||
|
public void onLinkAcceptNotice(LiveClient client, TikTokLinkAcceptNoticeEvent event) {}
|
||||||
|
public void onLinkSysKickOut(LiveClient client, TikTokLinkSysKickOutEvent event) {}
|
||||||
|
public void onLinkUserToast(LiveClient client, TikTokLinkUserToastEvent event) {}
|
||||||
|
|
||||||
|
public void onBarrage(LiveClient client, TikTokBarrageEvent event) {}
|
||||||
|
|
||||||
|
public void onGift(LiveClient client, TikTokGiftEvent event) {}
|
||||||
|
|
||||||
|
public void onGiftCombo(LiveClient client, TikTokGiftComboEvent event) {}
|
||||||
|
|
||||||
|
public void onLinkMicArmies(LiveClient client, TikTokLinkMicArmiesEvent event) {}
|
||||||
|
|
||||||
|
public void onEmote(LiveClient client, TikTokEmoteEvent event) {}
|
||||||
|
|
||||||
|
public void onUnauthorizedMember(LiveClient client, TikTokUnauthorizedMemberEvent event) {}
|
||||||
|
|
||||||
|
public void onInRoomBanner(LiveClient client, TikTokInRoomBannerEvent event) {}
|
||||||
|
|
||||||
|
public void onLinkMicMethod(LiveClient client, TikTokLinkMicMethodEvent event) {}
|
||||||
|
|
||||||
|
public void onSubscribe(LiveClient client, TikTokSubscribeEvent event) {}
|
||||||
|
|
||||||
|
public void onPoll(LiveClient client, TikTokPollEvent event) {}
|
||||||
|
|
||||||
|
public void onFollow(LiveClient client, TikTokFollowEvent event) {}
|
||||||
|
|
||||||
|
public void onComment(LiveClient client, TikTokCommentEvent event) {}
|
||||||
|
|
||||||
|
public void onHttpResponse(LiveClient client, TikTokHttpResponseEvent action) {}
|
||||||
|
|
||||||
|
public void onGoalUpdate(LiveClient client, TikTokGoalUpdateEvent event) {}
|
||||||
|
|
||||||
|
public void onRankUpdate(LiveClient client, TikTokRankUpdateEvent event) {}
|
||||||
|
|
||||||
|
public void onIMDelete(LiveClient client, TikTokIMDeleteEvent event) {}
|
||||||
|
|
||||||
|
public void onLiveEnded(LiveClient client, TikTokLiveEndedEvent event) {}
|
||||||
|
|
||||||
|
public void onError(LiveClient client, TikTokErrorEvent event) {}
|
||||||
|
|
||||||
|
public void onJoin(LiveClient client, TikTokJoinEvent event) {}
|
||||||
|
|
||||||
|
public void onRankText(LiveClient client, TikTokRankTextEvent event) {}
|
||||||
|
|
||||||
|
public void onShare(LiveClient client, TikTokShareEvent event) {}
|
||||||
|
|
||||||
|
public void onUnhandledMember(LiveClient client, TikTokUnhandledMemberEvent event) {}
|
||||||
|
|
||||||
|
public void onSubNotify(LiveClient client, TikTokSubNotifyEvent event) {}
|
||||||
|
|
||||||
|
public void onLinkMicBattle(LiveClient client, TikTokLinkMicBattleEvent event) {}
|
||||||
|
|
||||||
|
public void onDisconnected(LiveClient client, TikTokDisconnectedEvent event) {}
|
||||||
|
|
||||||
|
public void onUnhandledControl(LiveClient client, TikTokUnhandledControlEvent event) {}
|
||||||
|
|
||||||
|
public void onEvent(LiveClient client, TikTokEvent event) {}
|
||||||
|
|
||||||
|
public void onWebsocketResponse(LiveClient client, TikTokWebsocketResponseEvent event) {}
|
||||||
|
|
||||||
|
public void onWebsocketMessage(LiveClient client, TikTokWebsocketMessageEvent event) {}
|
||||||
|
|
||||||
|
public void onWebsocketUnhandledMessage(LiveClient client, TikTokWebsocketUnhandledMessageEvent event) {}
|
||||||
|
|
||||||
|
public void onReconnecting(LiveClient client, TikTokReconnectingEvent event) {}
|
||||||
|
}
|
||||||
@@ -1062,9 +1062,9 @@ message CohostListChangeContent {
|
|||||||
|
|
||||||
|
|
||||||
message LinkerListChangeContent {
|
message LinkerListChangeContent {
|
||||||
repeated ListUser linkedUsersList = 1;
|
repeated ListUser linkedUsers = 1;
|
||||||
repeated ListUser appliedUsersList = 2;
|
repeated ListUser appliedUsers = 2;
|
||||||
repeated ListUser connectingUsersList = 3;
|
repeated ListUser connectingUsers = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LinkerMediaChangeContent {
|
message LinkerMediaChangeContent {
|
||||||
|
|||||||
@@ -250,21 +250,21 @@ enum CommonContentCase {
|
|||||||
|
|
||||||
|
|
||||||
enum LinkMessageType {
|
enum LinkMessageType {
|
||||||
TPYE_LINKER_UNKNOWN = 0;
|
TYPE_LINKER_UNKNOWN = 0;
|
||||||
TYPE_LINKER_CREATE = 1;
|
TYPE_LINKER_CREATE = 1;
|
||||||
TYPE_LINKER_CLOSE = 2;
|
TYPE_LINKER_CLOSE = 2;
|
||||||
TYPE_LINKER_INVITE = 3;
|
TYPE_LINKER_INVITE = 3;
|
||||||
TYPE_LINKER_APPLY = 4;
|
TYPE_LINKER_APPLY = 4;
|
||||||
TYPE_LINKER_REPLY = 5;
|
TYPE_LINKER_REPLY = 5;
|
||||||
TPYE_LINKER_ENTER = 6;
|
TYPE_LINKER_ENTER = 6;
|
||||||
TPYE_LINKER_LEAVE = 7;
|
TYPE_LINKER_LEAVE = 7;
|
||||||
TYPE_LINKER_PERMIT = 8;
|
TYPE_LINKER_PERMIT = 8;
|
||||||
TPYE_LINKER_CANCEL_INVITE = 9;
|
TYPE_LINKER_CANCEL_INVITE = 9;
|
||||||
TYPE_LINKER_WAITING_LIST_CHANGE = 10;
|
TYPE_LINKER_WAITING_LIST_CHANGE = 10;
|
||||||
TYPE_LINKER_LINKED_LIST_CHANGE = 11;
|
TYPE_LINKER_LINKED_LIST_CHANGE = 11;
|
||||||
TYPE_LINKER_UPDATE_USER = 12;
|
TYPE_LINKER_UPDATE_USER = 12;
|
||||||
TPYE_LINKER_KICK_OUT = 13;
|
TYPE_LINKER_KICK_OUT = 13;
|
||||||
TPYE_LINKER_CANCEL_APPLY = 14;
|
TYPE_LINKER_CANCEL_APPLY = 14;
|
||||||
TYPE_LINKER_MUTE = 15;
|
TYPE_LINKER_MUTE = 15;
|
||||||
TYPE_LINKER_MATCH = 16;
|
TYPE_LINKER_MATCH = 16;
|
||||||
TYPE_LINKER_UPDATE_USER_SETTING = 17;
|
TYPE_LINKER_UPDATE_USER_SETTING = 17;
|
||||||
@@ -275,8 +275,8 @@ enum LinkMessageType {
|
|||||||
TYPE_LINKER_COHOST_LIST_CHANGE = 22;
|
TYPE_LINKER_COHOST_LIST_CHANGE = 22;
|
||||||
TYPE_LINKER_MEDIA_CHANGE = 23;
|
TYPE_LINKER_MEDIA_CHANGE = 23;
|
||||||
TYPE_LINKER_ACCEPT_NOTICE = 24;
|
TYPE_LINKER_ACCEPT_NOTICE = 24;
|
||||||
TPYE_LINKER_SYS_KICK_OUT = 101;
|
TYPE_LINKER_SYS_KICK_OUT = 101;
|
||||||
TPYE_LINKMIC_USER_TOAST = 102;
|
TYPE_LINKMIC_USER_TOAST = 102;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MessageType {
|
enum MessageType {
|
||||||
|
|||||||
@@ -805,7 +805,7 @@ message WebcastLinkMessage {
|
|||||||
LinkerListChangeContent ListChangeContent = 20;
|
LinkerListChangeContent ListChangeContent = 20;
|
||||||
CohostListChangeContent CohostListChangeContent = 21;
|
CohostListChangeContent CohostListChangeContent = 21;
|
||||||
LinkerMediaChangeContent MediaChangeContent = 22;
|
LinkerMediaChangeContent MediaChangeContent = 22;
|
||||||
LinkerAcceptNoticeContent ReplyAcceptNoticeContent = 23;
|
LinkerAcceptNoticeContent AcceptNoticeContent = 23;
|
||||||
LinkerSysKickOutContent SysKickOutContent = 101;
|
LinkerSysKickOutContent SysKickOutContent = 101;
|
||||||
LinkmicUserToastContent UserToastContent = 102;
|
LinkmicUserToastContent UserToastContent = 102;
|
||||||
string extra = 200;
|
string extra = 200;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ public class TikTokLive {
|
|||||||
return new TikTokLiveHttpClient();
|
return new TikTokLiveHttpClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
//I don't like it, but it is reasonable for now
|
|
||||||
private static GiftsManager giftsManager;
|
private static GiftsManager giftsManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import io.github.jwdeveloper.tiktok.data.events.control.TikTokPreConnectionEvent
|
|||||||
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
|
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.gift.*;
|
import io.github.jwdeveloper.tiktok.data.events.gift.*;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
|
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.link.*;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
|
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.room.*;
|
import io.github.jwdeveloper.tiktok.data.events.room.*;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.social.*;
|
import io.github.jwdeveloper.tiktok.data.events.social.*;
|
||||||
@@ -44,14 +45,15 @@ import io.github.jwdeveloper.tiktok.mappers.*;
|
|||||||
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
|
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
|
||||||
import io.github.jwdeveloper.tiktok.mappers.handlers.*;
|
import io.github.jwdeveloper.tiktok.mappers.handlers.*;
|
||||||
import io.github.jwdeveloper.tiktok.messages.webcast.*;
|
import io.github.jwdeveloper.tiktok.messages.webcast.*;
|
||||||
import io.github.jwdeveloper.tiktok.websocket.TikTokWebSocketClient;
|
import io.github.jwdeveloper.tiktok.websocket.*;
|
||||||
import io.github.jwdeveloper.tiktok.websocket.TikTokWebSocketOfflineClient;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static io.github.jwdeveloper.tiktok.messages.enums.LinkMessageType.*;
|
||||||
|
|
||||||
public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
||||||
|
|
||||||
protected final LiveClientSettings clientSettings;
|
protected final LiveClientSettings clientSettings;
|
||||||
@@ -215,6 +217,33 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
|||||||
var message = mapperHelper.bytesToWebcastObject(inputBytes, WebcastLinkMicArmies.class);
|
var message = mapperHelper.bytesToWebcastObject(inputBytes, WebcastLinkMicArmies.class);
|
||||||
return MappingResult.of(message, new TikTokLinkMicArmiesEvent(message));
|
return MappingResult.of(message, new TikTokLinkMicArmiesEvent(message));
|
||||||
});
|
});
|
||||||
|
mapper.forMessage(WebcastLinkMessage.class, ((inputBytes, messageName, mapperHelper) -> {
|
||||||
|
var message = mapperHelper.bytesToWebcastObject(inputBytes, WebcastLinkMessage.class);
|
||||||
|
return MappingResult.of(message, switch (message.getMessageType()) {
|
||||||
|
case TYPE_LINKER_INVITE -> new TikTokLinkInviteEvent(message);
|
||||||
|
case TYPE_LINKER_REPLY -> new TikTokLinkReplyEvent(message);
|
||||||
|
case TYPE_LINKER_CREATE -> new TikTokLinkCreateEvent(message);
|
||||||
|
case TYPE_LINKER_CLOSE -> new TikTokLinkCloseEvent(message);
|
||||||
|
case TYPE_LINKER_ENTER -> new TikTokLinkEnterEvent(message);
|
||||||
|
case TYPE_LINKER_LEAVE -> new TikTokLinkLeaveEvent(message);
|
||||||
|
case TYPE_LINKER_CANCEL_INVITE, TYPE_LINKER_CANCEL_APPLY -> new TikTokLinkCancelEvent(message);
|
||||||
|
case TYPE_LINKER_KICK_OUT -> new TikTokLinkKickOutEvent(message);
|
||||||
|
case TYPE_LINKER_LINKED_LIST_CHANGE -> new TikTokLinkLinkedListChangeEvent(message);
|
||||||
|
case TYPE_LINKER_UPDATE_USER -> new TikTokLinkUpdateUserEvent(message);
|
||||||
|
case TYPE_LINKER_WAITING_LIST_CHANGE, TYPE_LINKER_WAITING_LIST_CHANGE_V2 -> new TikTokLinkWaitListChangeEvent(message);
|
||||||
|
case TYPE_LINKER_MUTE -> new TikTokLinkMuteEvent(message);
|
||||||
|
case TYPE_LINKER_MATCH -> new TikTokLinkRandomMatchEvent(message);
|
||||||
|
case TYPE_LINKER_UPDATE_USER_SETTING -> new TikTokLinkUpdateUserSettingEvent(message);
|
||||||
|
case TYPE_LINKER_MIC_IDX_UPDATE -> new TikTokLinkMicIdxUpdateEvent(message);
|
||||||
|
case TYPE_LINKER_LINKED_LIST_CHANGE_V2 -> new TikTokLinkListChangeEvent(message);
|
||||||
|
case TYPE_LINKER_COHOST_LIST_CHANGE -> new TikTokLinkCohostListChangeEvent(message);
|
||||||
|
case TYPE_LINKER_MEDIA_CHANGE -> new TikTokLinkMediaChangeEvent(message);
|
||||||
|
case TYPE_LINKER_ACCEPT_NOTICE -> new TikTokLinkAcceptNoticeEvent(message);
|
||||||
|
case TYPE_LINKER_SYS_KICK_OUT -> new TikTokLinkSysKickOutEvent(message);
|
||||||
|
case TYPE_LINKMIC_USER_TOAST -> new TikTokLinkUserToastEvent(message);
|
||||||
|
default -> new TikTokLinkEvent(message);
|
||||||
|
});
|
||||||
|
}));
|
||||||
// mapper.webcastObjectToConstructor(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
|
// mapper.webcastObjectToConstructor(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
|
||||||
// mapper.webcastObjectToConstructor(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
|
// mapper.webcastObjectToConstructor(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
|
||||||
|
|
||||||
@@ -341,6 +370,111 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkInvite(EventConsumer<TikTokLinkInviteEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkInviteEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkReply(EventConsumer<TikTokLinkReplyEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkReplyEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkCreate(EventConsumer<TikTokLinkCreateEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkCreateEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkClose(EventConsumer<TikTokLinkCloseEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkCloseEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkEnter(EventConsumer<TikTokLinkEnterEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkEnterEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkLeave(EventConsumer<TikTokLinkLeaveEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkLeaveEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkCancel(EventConsumer<TikTokLinkCancelEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkCancelEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkKickOut(EventConsumer<TikTokLinkKickOutEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkKickOutEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkLinkedListChange(EventConsumer<TikTokLinkLinkedListChangeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkLinkedListChangeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkUpdateUser(EventConsumer<TikTokLinkUpdateUserEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkUpdateUserEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkWaitListChange(EventConsumer<TikTokLinkWaitListChangeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkWaitListChangeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkMute(EventConsumer<TikTokLinkMuteEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkMuteEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkRandomMatch(EventConsumer<TikTokLinkRandomMatchEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkRandomMatchEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkUpdateUserSettings(EventConsumer<TikTokLinkUpdateUserSettingEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkUpdateUserSettingEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkMicIdxUpdate(EventConsumer<TikTokLinkMicIdxUpdateEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkMicIdxUpdateEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkListChange(EventConsumer<TikTokLinkListChangeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkListChangeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkCohostListChange(EventConsumer<TikTokLinkCohostListChangeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkCohostListChangeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkMediaChange(EventConsumer<TikTokLinkMediaChangeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkMediaChangeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkAcceptNotice(EventConsumer<TikTokLinkAcceptNoticeEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkAcceptNoticeEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkSysKickOut(EventConsumer<TikTokLinkSysKickOutEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkSysKickOutEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TikTokLiveClientBuilder onLinkUserToast(EventConsumer<TikTokLinkUserToastEvent> event) {
|
||||||
|
eventHandler.subscribe(TikTokLinkUserToastEvent.class, event);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TikTokLiveClientBuilder onBarrage(EventConsumer<TikTokBarrageEvent> event) {
|
public TikTokLiveClientBuilder onBarrage(EventConsumer<TikTokBarrageEvent> event) {
|
||||||
eventHandler.subscribe(TikTokBarrageEvent.class, event);
|
eventHandler.subscribe(TikTokBarrageEvent.class, event);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
|||||||
public TikTokLiveHttpClient(HttpClientFactory factory, LiveClientSettings settings) {
|
public TikTokLiveHttpClient(HttpClientFactory factory, LiveClientSettings settings) {
|
||||||
this.httpFactory = factory;
|
this.httpFactory = factory;
|
||||||
this.clientSettings = settings;
|
this.clientSettings = settings;
|
||||||
this.logger = LoggerFactory.create("HttpClient", clientSettings);
|
this.logger = LoggerFactory.create("HttpClient-"+hashCode(), clientSettings);
|
||||||
liveUserDataMapper = new LiveUserDataMapper();
|
liveUserDataMapper = new LiveUserDataMapper();
|
||||||
liveDataMapper = new LiveDataMapper();
|
liveDataMapper = new LiveDataMapper();
|
||||||
giftsDataMapper = new GiftsDataMapper();
|
giftsDataMapper = new GiftsDataMapper();
|
||||||
@@ -178,7 +178,7 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
|||||||
try {
|
try {
|
||||||
var resultHeader = ActionResult.of(credentialsResponse.headers().firstValue("x-set-tt-cookie"));
|
var resultHeader = ActionResult.of(credentialsResponse.headers().firstValue("x-set-tt-cookie"));
|
||||||
if (resultHeader.isFailure()) {
|
if (resultHeader.isFailure()) {
|
||||||
logger.warning("SignServer Headers: "+request.getRoomId()+" - "+credentialsResponse.headers().map());
|
logger.warning("Sign Server Headers: "+request.getRoomId()+" - "+credentialsResponse.headers().map());
|
||||||
throw new TikTokSignServerException("Sign server did not return the x-set-tt-cookie header - "+result);
|
throw new TikTokSignServerException("Sign server did not return the x-set-tt-cookie header - "+result);
|
||||||
}
|
}
|
||||||
var websocketCookie = resultHeader.getContent();
|
var websocketCookie = resultHeader.getContent();
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class ActionResult<T> {
|
|||||||
.setPrettyPrinting().create();
|
.setPrettyPrinting().create();
|
||||||
|
|
||||||
private boolean success = true;
|
private boolean success = true;
|
||||||
private T content;
|
|
||||||
private String message;
|
private String message;
|
||||||
|
private T content;
|
||||||
@Accessors(chain = true, fluent = true)
|
@Accessors(chain = true, fluent = true)
|
||||||
private ActionResult<?> previous;
|
private ActionResult<?> previous;
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ public class ActionResult<T> {
|
|||||||
public JsonObject toJson() {
|
public JsonObject toJson() {
|
||||||
JsonObject map = new JsonObject();
|
JsonObject map = new JsonObject();
|
||||||
map.addProperty("success", success);
|
map.addProperty("success", success);
|
||||||
map.add("content", gson.toJsonTree(content));
|
|
||||||
map.addProperty("message", message);
|
map.addProperty("message", message);
|
||||||
|
map.add("content", gson.toJsonTree(content));
|
||||||
map.add("previous", hasPrevious() ? previous.toJson() : null);
|
map.add("previous", hasPrevious() ? previous.toJson() : null);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.net.http.*;
|
import java.net.http.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
|
import java.time.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.*;
|
import java.util.regex.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -47,7 +48,21 @@ public class HttpClient {
|
|||||||
try {
|
try {
|
||||||
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
|
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
|
||||||
var result = ActionResult.of(response);
|
var result = ActionResult.of(response);
|
||||||
return response.statusCode() != 200 ? result.message("HttpResponse Code: ", response.statusCode()).failure() : result.success();
|
return switch (response.statusCode()) {
|
||||||
|
case 420 -> result.message("HttpResponse Code:", response.statusCode(), "| IP Cloudflare Blocked.").failure();
|
||||||
|
case 429 -> {
|
||||||
|
var wait = response.headers().firstValue("ratelimit-reset");
|
||||||
|
if (wait.isEmpty())
|
||||||
|
yield result.message("HttpResponse Code:", response.statusCode(), "| Sign server rate limit reached. Try again later.").failure();
|
||||||
|
Duration duration = Duration.ofSeconds(Long.parseLong(wait.get()));
|
||||||
|
yield result.message("HttpResponse Code:", response.statusCode(),
|
||||||
|
String.format("| Sign server rate limit reached. Try again in %02d:%02d.", duration.toMinutesPart(), duration.toSecondsPart())).failure();
|
||||||
|
}
|
||||||
|
case 500, 501, 502, 503 -> result.message("HttpResponse Code:", response.statusCode(), "| Sign server Error. Try again later.").failure();
|
||||||
|
case 504 -> result.message("HttpResponse Code:", response.statusCode(), "| Sign server Timeout. Try again later.").failure();
|
||||||
|
case 200 -> result.success();
|
||||||
|
default -> result.message("HttpResponse Code:", response.statusCode()).failure();
|
||||||
|
};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new TikTokLiveRequestException(e);
|
throw new TikTokLiveRequestException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
socksConnection.setSSLSocketFactory(sc.getSocketFactory());
|
socksConnection.setSSLSocketFactory(sc.getSocketFactory());
|
||||||
socksConnection.setConnectTimeout(httpClientSettings.getTimeout().toMillisPart());
|
socksConnection.setConnectTimeout(httpClientSettings.getTimeout().toMillisPart());
|
||||||
socksConnection.setReadTimeout(httpClientSettings.getTimeout().toMillisPart());
|
socksConnection.setReadTimeout(httpClientSettings.getTimeout().toMillisPart());
|
||||||
|
httpClientSettings.getHeaders().forEach(socksConnection::setRequestProperty);
|
||||||
|
|
||||||
byte[] body = socksConnection.getInputStream().readAllBytes();
|
byte[] body = socksConnection.getInputStream().readAllBytes();
|
||||||
|
|
||||||
|
|||||||
@@ -96,16 +96,17 @@ public class TikTokListenersManager implements ListenersManager {
|
|||||||
m.isAnnotationPresent(TikTokEventObserver.class)).toList();
|
m.isAnnotationPresent(TikTokEventObserver.class)).toList();
|
||||||
var eventsMap = new HashMap<Class<?>, List<EventConsumer<?>>>();
|
var eventsMap = new HashMap<Class<?>, List<EventConsumer<?>>>();
|
||||||
for (var method : methods) {
|
for (var method : methods) {
|
||||||
var eventClazz = method.getParameterTypes()[1];
|
var liveclientClass = method.getParameterTypes()[0];
|
||||||
|
var eventClass = method.getParameterTypes()[1];
|
||||||
|
|
||||||
if (eventClazz.isAssignableFrom(LiveClient.class) &&
|
if (!LiveClient.class.isAssignableFrom(liveclientClass) && !liveclientClass.equals(LiveClient.class)) {
|
||||||
!eventClazz.equals(LiveClient.class)) {
|
throw new TikTokEventListenerMethodException("Method " + method.getName() + "() 1st parameter must be instance of " + LiveClient.class.getName()
|
||||||
throw new TikTokEventListenerMethodException("Method " + method.getName() + "() 1nd parameter must instance of " + LiveClient.class.getName());
|
+ " | Invalid parameter class: "+liveclientClass.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventClazz.isAssignableFrom(TikTokEvent.class) &&
|
if (!TikTokEvent.class.isAssignableFrom(eventClass) && !eventClass.equals(TikTokEvent.class)) {
|
||||||
!eventClazz.equals(TikTokEvent.class)) {
|
throw new TikTokEventListenerMethodException("Method " + method.getName() + "() 2nd parameter must be instance of " + TikTokEvent.class.getName()
|
||||||
throw new TikTokEventListenerMethodException("Method " + method.getName() + "() 2nd parameter must instance of " + TikTokEvent.class.getName());
|
+ " | Invalid parameter class: "+eventClass.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
EventConsumer eventMethodRef = (liveClient, event) ->
|
EventConsumer eventMethodRef = (liveClient, event) ->
|
||||||
@@ -117,7 +118,7 @@ public class TikTokListenersManager implements ListenersManager {
|
|||||||
throw new TikTokEventListenerMethodException(e);
|
throw new TikTokEventListenerMethodException(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
eventsMap.computeIfAbsent(eventClazz, (a) -> new ArrayList<>()).add(eventMethodRef);
|
eventsMap.computeIfAbsent(eventClass, (a) -> new ArrayList<>()).add(eventMethodRef);
|
||||||
}
|
}
|
||||||
return new ListenerBindingModel(listener, eventsMap);
|
return new ListenerBindingModel(listener, eventsMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.java_websocket.client.WebSocketClient;
|
|||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class TikTokWebSocketClient implements SocketClient {
|
public class TikTokWebSocketClient implements SocketClient {
|
||||||
private final LiveClientSettings clientSettings;
|
private final LiveClientSettings clientSettings;
|
||||||
@@ -62,7 +63,7 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
|
|
||||||
messageHandler.handle(liveClient, connectionData.getWebcastResponse());
|
messageHandler.handle(liveClient, connectionData.getWebcastResponse());
|
||||||
|
|
||||||
var headers = clientSettings.getHttpSettings().getHeaders();
|
var headers = new HashMap<>(clientSettings.getHttpSettings().getHeaders());
|
||||||
headers.put("Cookie", connectionData.getWebsocketCookies());
|
headers.put("Cookie", connectionData.getWebsocketCookies());
|
||||||
webSocketClient = new TikTokWebSocketListener(connectionData.getWebsocketUrl(),
|
webSocketClient = new TikTokWebSocketListener(connectionData.getWebsocketUrl(),
|
||||||
headers,
|
headers,
|
||||||
|
|||||||
@@ -22,12 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.gifts;
|
package io.github.jwdeveloper.tiktok.gifts;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftOld;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.models.Picture;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>extension-collector</artifactId>
|
<artifactId>extension-collector</artifactId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ package io.github.jwdeveloper.tiktok;
|
|||||||
import io.github.jwdeveloper.tiktok.extension.recorder.TikTokLiveRecorder;
|
import io.github.jwdeveloper.tiktok.extension.recorder.TikTokLiveRecorder;
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.event.TikTokLiveRecorderStartedEvent;
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.event.TikTokLiveRecorderStartedEvent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class RecorderExample {
|
public class RecorderExample {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -39,11 +41,10 @@ public class RecorderExample {
|
|||||||
{
|
{
|
||||||
event.getException().printStackTrace();
|
event.getException().printStackTrace();
|
||||||
})
|
})
|
||||||
.addListener(TikTokLiveRecorder.use(recorderSettings ->
|
.addListener(TikTokLiveRecorder.use((recorderSettings, liveClient) ->
|
||||||
{
|
{
|
||||||
recorderSettings.setFfmpegPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\libs\\ffmpeg.exe");
|
recorderSettings.setFfmpegPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\libs\\ffmpeg.exe");
|
||||||
recorderSettings.setOutputPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\out");
|
recorderSettings.setOutputFile(new File("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\out", "test.flv"));
|
||||||
recorderSettings.setOutputFileName("test.flv");
|
|
||||||
}))
|
}))
|
||||||
.onEvent(TikTokLiveRecorderStartedEvent.class, (liveClient, event) ->
|
.onEvent(TikTokLiveRecorderStartedEvent.class, (liveClient, event) ->
|
||||||
{
|
{
|
||||||
@@ -52,4 +53,4 @@ public class RecorderExample {
|
|||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ Maven
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
||||||
<artifactId>Client</artifactId>
|
<artifactId>Client</artifactId>
|
||||||
<version>1.6.0-Release</version>
|
<version>1.7.0-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
|
|||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.control.TikTokConnectingEvent;
|
import io.github.jwdeveloper.tiktok.data.events.control.TikTokConnectingEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketResponseEvent;
|
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketResponseEvent;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.LiveDataCollector;
|
import io.github.jwdeveloper.tiktok.extension.collector.api.LiveDataCollector;
|
||||||
@@ -16,22 +17,20 @@ import org.bson.Document;
|
|||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class DataCollectorListener implements LiveDataCollector {
|
public class DataCollectorListener implements LiveDataCollector {
|
||||||
|
|
||||||
private final Storage storage;
|
private final Storage storage;
|
||||||
private final CollectorListenerSettings settings;
|
private final CollectorListenerSettings settings;
|
||||||
private String roomId;
|
private String roomId, userName;
|
||||||
private String userName;
|
|
||||||
|
|
||||||
public DataCollectorListener(Storage collection, CollectorListenerSettings settings) {
|
public DataCollectorListener(Storage collection, CollectorListenerSettings settings) {
|
||||||
this.storage = collection;
|
this.storage = collection;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
private void onResponse(LiveClient liveClient, TikTokWebsocketResponseEvent event) {
|
private void onResponse(LiveClient liveClient, TikTokWebsocketResponseEvent event) {
|
||||||
includeResponse(liveClient, event.getResponse());
|
includeResponse(liveClient, event.getResponse());
|
||||||
@@ -40,13 +39,12 @@ public class DataCollectorListener implements LiveDataCollector {
|
|||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
private void onEvent(LiveClient liveClient, TikTokEvent event) {
|
private void onEvent(LiveClient liveClient, TikTokEvent event) {
|
||||||
if (event instanceof TikTokConnectingEvent) {
|
if (event instanceof TikTokConnectingEvent)
|
||||||
userName = liveClient.getRoomInfo().getHostName();
|
userName = liveClient.getRoomInfo().getHostName();
|
||||||
|
else if (event instanceof TikTokRoomInfoEvent && roomId == null)
|
||||||
roomId = liveClient.getRoomInfo().getRoomId();
|
roomId = liveClient.getRoomInfo().getRoomId();
|
||||||
}
|
else if (event instanceof TikTokErrorEvent)
|
||||||
if (event instanceof TikTokErrorEvent) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
includeEvent(liveClient, event);
|
includeEvent(liveClient, event);
|
||||||
}
|
}
|
||||||
@@ -57,7 +55,6 @@ public class DataCollectorListener implements LiveDataCollector {
|
|||||||
includeError(liveClient, event);
|
includeError(liveClient, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void includeResponse(LiveClient liveClient, WebcastResponse message) {
|
private void includeResponse(LiveClient liveClient, WebcastResponse message) {
|
||||||
var messageContent = Base64.getEncoder().encodeToString(message.toByteArray());
|
var messageContent = Base64.getEncoder().encodeToString(message.toByteArray());
|
||||||
insertDocument(liveClient, createDocument("response", "webcast", messageContent));
|
insertDocument(liveClient, createDocument("response", "webcast", messageContent));
|
||||||
@@ -86,33 +83,26 @@ public class DataCollectorListener implements LiveDataCollector {
|
|||||||
var content = sw.toString();
|
var content = sw.toString();
|
||||||
var contentBase64 = Base64.getEncoder().encodeToString(content.getBytes());
|
var contentBase64 = Base64.getEncoder().encodeToString(content.getBytes());
|
||||||
var doc = createDocument("error", exceptionName, contentBase64);
|
var doc = createDocument("error", exceptionName, contentBase64);
|
||||||
if (exception instanceof TikTokLiveMessageException ex) {
|
if (exception instanceof TikTokLiveMessageException ex)
|
||||||
doc.append("message", ex.messageToBase64())
|
doc.append("message", ex.messageToBase64()).append("response", ex.webcastResponseToBase64());
|
||||||
.append("response", ex.webcastResponseToBase64());
|
|
||||||
}
|
|
||||||
insertDocument(client, doc);
|
insertDocument(client, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void insertDocument(LiveClient client, Document document) {
|
private void insertDocument(LiveClient client, Document document) {
|
||||||
if (!settings.getFilter().execute(client, document)) {
|
if (settings.getFilter().execute(client, document))
|
||||||
return;
|
storage.insert(document);
|
||||||
}
|
}
|
||||||
storage.insert(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Document createDocument(String dataType, String dataTypeName, String content) {
|
private Document createDocument(String dataType, String dataTypeName, String content) {
|
||||||
var doc = new Document();
|
var doc = new Document();
|
||||||
doc.append("roomId", roomId);
|
doc.append("roomId", roomId);
|
||||||
for (var entry : settings.getExtraFields().entrySet()) {
|
for (var entry : settings.getExtraFields().entrySet())
|
||||||
doc.append(entry.getKey(), entry.getValue());
|
doc.append(entry.getKey(), entry.getValue());
|
||||||
}
|
|
||||||
doc.append("tiktokUser", userName);
|
doc.append("tiktokUser", userName);
|
||||||
doc.append("dataType", dataType);
|
doc.append("dataType", dataType);
|
||||||
doc.append("dataTypeName", dataTypeName);
|
doc.append("dataTypeName", dataTypeName);
|
||||||
doc.append("content", content);
|
doc.append("content", content);
|
||||||
doc.append("createdAt", new Date());
|
doc.append("createdAt", LocalDateTime.now().toString());
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>extension-recorder</artifactId>
|
<artifactId>extension-recorder</artifactId>
|
||||||
|
|||||||
@@ -25,18 +25,19 @@ package io.github.jwdeveloper.tiktok.extension.recorder;
|
|||||||
import io.github.jwdeveloper.tiktok.extension.recorder.api.LiveRecorder;
|
import io.github.jwdeveloper.tiktok.extension.recorder.api.LiveRecorder;
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.RecorderListener;
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.RecorderListener;
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.RecorderSettings;
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.RecorderSettings;
|
||||||
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.*;
|
||||||
|
|
||||||
public class TikTokLiveRecorder
|
public class TikTokLiveRecorder
|
||||||
{
|
{
|
||||||
public static LiveRecorder use(Consumer<RecorderSettings> consumer)
|
public static LiveRecorder use(BiConsumer<RecorderSettings, LiveClient> consumer)
|
||||||
{
|
{
|
||||||
return new RecorderListener(consumer);
|
return new RecorderListener(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LiveRecorder use()
|
public static LiveRecorder use()
|
||||||
{
|
{
|
||||||
return use(x ->{});
|
return use((x,y) ->{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,26 +37,23 @@ import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
|||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.function.*;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
|
||||||
|
|
||||||
public class RecorderListener implements LiveRecorder {
|
public class RecorderListener implements LiveRecorder {
|
||||||
|
|
||||||
private final Consumer<RecorderSettings> consumer;
|
private final BiConsumer<RecorderSettings, LiveClient> consumer;
|
||||||
private RecorderSettings settings;
|
private RecorderSettings settings;
|
||||||
private DownloadData downloadData;
|
private DownloadData downloadData;
|
||||||
private Thread liveDownloadThread;
|
private Thread liveDownloadThread;
|
||||||
|
|
||||||
public RecorderListener(Consumer<RecorderSettings> consumer) {
|
public RecorderListener(BiConsumer<RecorderSettings, LiveClient> consumer) {
|
||||||
this.consumer = consumer;
|
this.consumer = consumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
private void onResponse(LiveClient liveClient, TikTokRoomDataResponseEvent event) {
|
private void onResponse(LiveClient liveClient, TikTokRoomDataResponseEvent event) {
|
||||||
settings = RecorderSettings.DEFAULT();
|
settings = RecorderSettings.DEFAULT();
|
||||||
consumer.accept(settings);
|
consumer.accept(settings, liveClient);
|
||||||
|
|
||||||
var json = event.getLiveData().getJson();
|
var json = event.getLiveData().getJson();
|
||||||
|
|
||||||
@@ -76,10 +73,9 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
if (isConnected())
|
if (isConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
liveDownloadThread = new Thread(() -> {
|
liveDownloadThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
liveClient.getLogger().info("Recording started");
|
liveClient.getLogger().info("Recording started "+liveClient.getRoomInfo().getHostName());
|
||||||
var url = new URL(downloadData.getFullUrl());
|
var url = new URL(downloadData.getFullUrl());
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
var headers = LiveClientSettings.DefaultRequestHeaders();
|
var headers = LiveClientSettings.DefaultRequestHeaders();
|
||||||
@@ -87,18 +83,17 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
connection.setRequestProperty(entry.getKey(), entry.getValue());
|
connection.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = settings.getOutputPath() + File.separator + settings.getOutputFileName();
|
var file = settings.getOutputFile();
|
||||||
var file = new File(path);
|
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
|
||||||
try (
|
try (
|
||||||
var in = connection.getInputStream();
|
var in = connection.getInputStream();
|
||||||
var fos = new FileOutputStream(file)
|
var fos = new FileOutputStream(file)
|
||||||
) {
|
) {
|
||||||
byte[] dataBuffer = new byte[1024];
|
byte[] dataBuffer = new byte[1024];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while (liveClient.getRoomInfo().getConnectionState() == ConnectionState.CONNECTED && (bytesRead = in.read(dataBuffer)) != -1) {
|
while ((!settings.isStopOnDisconnect() || liveClient.getRoomInfo().getConnectionState() == ConnectionState.CONNECTED) && (bytesRead = in.read(dataBuffer)) != -1) {
|
||||||
fos.write(dataBuffer, 0, bytesRead);
|
fos.write(dataBuffer, 0, bytesRead);
|
||||||
fos.flush();
|
fos.flush();
|
||||||
}
|
}
|
||||||
@@ -113,11 +108,10 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
|
|
||||||
var recordingStartedEvent = new TikTokLiveRecorderStartedEvent(downloadData);
|
var recordingStartedEvent = new TikTokLiveRecorderStartedEvent(downloadData);
|
||||||
liveClient.publishEvent(recordingStartedEvent);
|
liveClient.publishEvent(recordingStartedEvent);
|
||||||
if (recordingStartedEvent.isCanceled()) {
|
if (recordingStartedEvent.isCanceled())
|
||||||
liveClient.getLogger().info("Recording cancelled");
|
liveClient.getLogger().info("Recording cancelled");
|
||||||
return;
|
else
|
||||||
}
|
liveDownloadThread.start();
|
||||||
liveDownloadThread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveFormat;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -36,10 +37,8 @@ public class RecorderSettings {
|
|||||||
private String ffmpegPath;
|
private String ffmpegPath;
|
||||||
private String quality;
|
private String quality;
|
||||||
private String format;
|
private String format;
|
||||||
private String outputPath;
|
private File outputFile;
|
||||||
private String outputFileName;
|
|
||||||
private Function<String,DownloadData> prepareDownloadData;
|
private Function<String,DownloadData> prepareDownloadData;
|
||||||
private boolean startOnConnected;
|
|
||||||
private boolean stopOnDisconnect = true;
|
private boolean stopOnDisconnect = true;
|
||||||
|
|
||||||
public static RecorderSettings DEFAULT() {
|
public static RecorderSettings DEFAULT() {
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.6.1-Release</version>
|
<version>1.7.1-Release</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>API</module>
|
<module>API</module>
|
||||||
<module>Client</module>
|
<module>Client</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user