Skip to content

Commit 0d384f0

Browse files
authored
Merge pull request #28 from jwdeveloper/develop-1-0-7
Develop 1 0 7
2 parents 4f3ec1c + 3832db1 commit 0d384f0

File tree

73 files changed

+46598
-7879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+46598
-7879
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
package io.github.jwdeveloper.tiktok.data.dto;
24+
25+
import lombok.AllArgsConstructor;
26+
import lombok.Data;
27+
import lombok.Value;
28+
29+
import java.time.Duration;
30+
31+
@Data
32+
@AllArgsConstructor
33+
public class MessageMetaData
34+
{
35+
private Duration handlingTime;
36+
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/dto/TikTokUserInfo.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
123
package io.github.jwdeveloper.tiktok.data.dto;
224

325
import lombok.AllArgsConstructor;

API/src/main/java/io/github/jwdeveloper/tiktok/utils/CancelationToken.java renamed to API/src/main/java/io/github/jwdeveloper/tiktok/data/events/CustomEvent.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,24 @@
2020
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2121
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
23-
package io.github.jwdeveloper.tiktok.utils;
23+
package io.github.jwdeveloper.tiktok.data.events;
2424

25-
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
25+
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
26+
import io.github.jwdeveloper.tiktok.annotations.EventType;
27+
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
2628

27-
public class CancelationToken
28-
{
29-
private boolean isCanceled =false;
29+
import io.github.jwdeveloper.tiktok.data.models.users.User;
30+
import lombok.Data;
3031

31-
public void cancel()
32-
{
33-
isCanceled =true;
34-
}
35-
36-
public boolean isCancel()
37-
{
38-
39-
return isCanceled;
40-
}
4132

42-
public void throwIfCancel()
43-
{
44-
if(!isCanceled)
45-
{
46-
return;
47-
}
48-
throw new TikTokLiveException("Token requested cancelation");
49-
}
50-
51-
public boolean isNotCancel()
52-
{
53-
return !isCancel();
54-
}
33+
@Data
34+
@EventMeta(eventType = EventType.Message)
35+
public class CustomEvent extends TikTokHeaderEvent {
36+
private final User user;
37+
private final String title;
5538

56-
public static CancelationToken create()
57-
{
58-
return new CancelationToken();
39+
public CustomEvent(User user, String title) {
40+
this.user = user;
41+
this.title = title;
5942
}
6043
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLinkEvent.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,10 @@
3434
@Getter
3535
@EventMeta(eventType = EventType.Message)
3636
public class TikTokLinkEvent extends TikTokHeaderEvent {
37-
private final String token;
3837

39-
private User user;
40-
41-
private final List<User> otherUsers;
4238

4339
public TikTokLinkEvent(WebcastLinkMessage msg) {
4440
super(msg.getCommon());
45-
token = msg.getToken();
46-
if (msg.getUser().getUser().hasUser()) {
47-
user = new User(msg.getUser().getUser().getUser());
48-
}
49-
otherUsers = msg.getUser().getOtherUsersList().stream().map(e -> new User(e.getUser())).toList();
41+
5042
}
5143
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
123
package io.github.jwdeveloper.tiktok.data.events;
224

325
import io.github.jwdeveloper.tiktok.annotations.EventMeta;

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,30 @@
2626
import io.github.jwdeveloper.tiktok.annotations.EventType;
2727
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
2828
import io.github.jwdeveloper.tiktok.data.models.users.User;
29+
import io.github.jwdeveloper.tiktok.data.models.users.UserAttribute;
2930
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
31+
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSubNotifyMessage;
3032
import lombok.Getter;
3133

3234
/**
3335
* Triggers when a user creates a subscription.
3436
*/
3537
@Getter
3638
@EventMeta(eventType = EventType.Message)
37-
public class TikTokSubscribeEvent extends TikTokHeaderEvent {
38-
private User user;
39+
public class TikTokSubscribeEvent extends TikTokHeaderEvent
40+
{
41+
private final User user;
3942

40-
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
41-
super(msg.getCommon());
43+
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
44+
super(msg.getCommon());
45+
user = User.map(msg.getUser());
46+
user.addAttribute(UserAttribute.Subscriber);
47+
}
4248

43-
if(msg.hasUser())
44-
{
45-
user = new User(msg.getUser());
49+
public TikTokSubscribeEvent(WebcastSubNotifyMessage msg) {
50+
super(msg.getCommon());
51+
user = User.map(msg.getUser());
52+
user.addAttribute(UserAttribute.Subscriber);
4653
}
47-
}
4854

4955
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
123
package io.github.jwdeveloper.tiktok.data.events.room;
224

325
import io.github.jwdeveloper.tiktok.annotations.EventMeta;

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
2626
import io.github.jwdeveloper.tiktok.annotations.EventType;
27+
import io.github.jwdeveloper.tiktok.data.dto.MessageMetaData;
2728
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
29+
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
2830
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
2931
import lombok.AllArgsConstructor;
3032
import lombok.Getter;
@@ -34,22 +36,32 @@
3436

3537

3638
/**
37-
* Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
39+
* Triggered every time TikTok sends data. Data incoming as protobuf message.
40+
* You can deserialize the binary object depending on the use case.
3841
*/
3942
@Getter
4043
@AllArgsConstructor
4144
@EventMeta(eventType = EventType.Debug)
42-
public class TikTokWebsocketMessageEvent extends TikTokEvent
43-
{
44-
private TikTokEvent event;
45+
public class TikTokWebsocketMessageEvent extends TikTokEvent {
4546

47+
/*
48+
* Original message that is coming from TikTok
49+
* message.method - Name of message type, for example "WebcastGiftMessage"
50+
* message.payload - Bytes array that contains actual data of message.
51+
* Example of parsing, WebcastGiftMessage giftMessage = WebcastGiftMessage.parseFrom(message.getPayload());
52+
*/
4653
private WebcastResponse.Message message;
4754

48-
private MetaData metaData;
55+
/*
56+
* TikTokLiveJava event that was created from TikTok message data
57+
* Example: TikTokGiftEvent
58+
*/
59+
private TikTokEvent event;
60+
61+
/*
62+
* Metadata information about mapping message to event, such as time and stuff
63+
*/
64+
private MessageMetaData metaData;
65+
4966

50-
@Value
51-
public static class MetaData
52-
{
53-
Duration handlingTime;
54-
}
5567
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketUnhandledMessageEvent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ public class TikTokWebsocketUnhandledMessageEvent extends TikTokUnhandledEvent<W
3939
public TikTokWebsocketUnhandledMessageEvent(WebcastResponse.Message data) {
4040
super(data);
4141
}
42+
43+
public WebcastResponse.Message getMessage()
44+
{
45+
return this.getData();
46+
}
4247
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/chest/Chest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
123
package io.github.jwdeveloper.tiktok.data.models.chest;
224

325

0 commit comments

Comments
 (0)