mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
- change method name from onMapping, to mappings
This commit is contained in:
@@ -24,7 +24,6 @@ package io.github.jwdeveloper.tiktok.live.builder;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.dependance.implementation.DependanceContainerBuilder;
|
import io.github.jwdeveloper.dependance.implementation.DependanceContainerBuilder;
|
||||||
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
||||||
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
|
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import io.github.jwdeveloper.tiktok.mappers.LiveMapper;
|
import io.github.jwdeveloper.tiktok.mappers.LiveMapper;
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ public interface LiveClientBuilder extends EventsBuilder<LiveClientBuilder> {
|
|||||||
* @param onCustomMappings lambda method
|
* @param onCustomMappings lambda method
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
LiveClientBuilder onMapping(Consumer<LiveMapper> onCustomMappings);
|
LiveClientBuilder mappings(Consumer<LiveMapper> onCustomMappings);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
|||||||
this.onCustomDependencies = new ArrayList<>();
|
this.onCustomDependencies = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveClientBuilder onMapping(Consumer<LiveMapper> consumer) {
|
public LiveClientBuilder mappings(Consumer<LiveMapper> consumer) {
|
||||||
this.onCustomMappings.add(consumer);
|
this.onCustomMappings.add(consumer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ public class ConnectionExample {
|
|||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
showLogo();
|
showLogo();
|
||||||
|
|
||||||
var gifts = TikTokLive.gifts();
|
|
||||||
|
|
||||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||||
.configure(clientSettings ->
|
.configure(clientSettings ->
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class CustomMappingExample {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TikTokLive.newClient("saszareznikow")
|
TikTokLive.newClient("saszareznikow")
|
||||||
.onMapping(mapper ->
|
.mappings(mapper ->
|
||||||
{
|
{
|
||||||
mapper.forMessage(WebcastChatMessage.class)
|
mapper.forMessage(WebcastChatMessage.class)
|
||||||
.onBeforeMapping((inputBytes, messageName, mapperHelper) ->
|
.onBeforeMapping((inputBytes, messageName, mapperHelper) ->
|
||||||
@@ -56,7 +56,6 @@ public class CustomMappingExample {
|
|||||||
System.out.println("onAfter mapping, " + source.getClass().getSimpleName() + " was mapped to " + events.size() + " events");
|
System.out.println("onAfter mapping, " + source.getClass().getSimpleName() + " was mapped to " + events.size() + " events");
|
||||||
return events;
|
return events;
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
There might be cast that we don't have Webcast class for incoming message from TikTok
|
There might be cast that we don't have Webcast class for incoming message from TikTok
|
||||||
`mapperHelper.bytesToProtoBufferStructure` but you can still investigate message structure
|
`mapperHelper.bytesToProtoBufferStructure` but you can still investigate message structure
|
||||||
|
|||||||
@@ -28,21 +28,18 @@ 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.gift.TikTokGiftEvent;
|
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
|
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
|
||||||
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
|
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ListenerExample
|
public class ListenerExample {
|
||||||
{
|
|
||||||
// <code>
|
// <code>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Listeners are an alternative way of handling events.
|
||||||
* Listeners are an alternative way of handling events.
|
* I would to suggest to use then when logic of handing event
|
||||||
* I would to suggest to use then when logic of handing event
|
* is more complex
|
||||||
* is more complex
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
showLogo();
|
showLogo();
|
||||||
@@ -55,24 +52,21 @@ public class ListenerExample
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Method must meet 2 requirements to be detected
|
||||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
* - must have @TikTokEventObserver annotation
|
||||||
* - must have @TikTokEventObserver annotation
|
* - must have 1 parameter of type that extending TikTokEvent
|
||||||
* - must have 2 parameters
|
|
||||||
* - first parameter must be LiveClient
|
|
||||||
* - second must be class that extending TikTokEvent
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static class CustomListener implements TikTokEventListener {
|
public static class CustomListener {
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
public void onLike(TikTokLikeEvent event) {
|
||||||
System.out.println(event.toString());
|
System.out.println(event.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
public void onError(TikTokErrorEvent event, LiveClient liveClient) {
|
||||||
// event.getException().printStackTrace();
|
// event.getException().printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventObserver
|
||||||
@@ -103,9 +97,8 @@ public class ListenerExample
|
|||||||
}
|
}
|
||||||
|
|
||||||
// </code>
|
// </code>
|
||||||
private static void showLogo()
|
private static void showLogo() {
|
||||||
{
|
System.out.println(ConsoleColors.GREEN + """
|
||||||
System.out.println(ConsoleColors.GREEN+"""
|
|
||||||
|
|
||||||
_____ _ _ _____ _ _ _ \s
|
_____ _ _ _____ _ _ _ \s
|
||||||
|_ _(_) | _|_ _|__ | | _| | (_)_ _____\s
|
|_ _(_) | _|_ _|__ | | _| | (_)_ _____\s
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class RecorderExample {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
TikTokLive.newClient("bangbetmenygy")
|
TikTokLive.newClient("bangbetmenygy")
|
||||||
.configure(liveClientSettings ->
|
.configure(liveClientSettings ->
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user