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.tiktok.data.settings.LiveClientSettings;
|
||||
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
import io.github.jwdeveloper.tiktok.mappers.LiveMapper;
|
||||
|
||||
@@ -42,7 +41,7 @@ public interface LiveClientBuilder extends EventsBuilder<LiveClientBuilder> {
|
||||
* @param onCustomMappings lambda method
|
||||
* @return
|
||||
*/
|
||||
LiveClientBuilder onMapping(Consumer<LiveMapper> onCustomMappings);
|
||||
LiveClientBuilder mappings(Consumer<LiveMapper> onCustomMappings);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
|
||||
this.onCustomDependencies = new ArrayList<>();
|
||||
}
|
||||
|
||||
public LiveClientBuilder onMapping(Consumer<LiveMapper> consumer) {
|
||||
public LiveClientBuilder mappings(Consumer<LiveMapper> consumer) {
|
||||
this.onCustomMappings.add(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,6 @@ public class ConnectionExample {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
showLogo();
|
||||
|
||||
var gifts = TikTokLive.gifts();
|
||||
|
||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings ->
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CustomMappingExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TikTokLive.newClient("saszareznikow")
|
||||
.onMapping(mapper ->
|
||||
.mappings(mapper ->
|
||||
{
|
||||
mapper.forMessage(WebcastChatMessage.class)
|
||||
.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");
|
||||
return events;
|
||||
});
|
||||
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -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.gift.TikTokGiftEvent;
|
||||
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.utils.ConsoleColors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ListenerExample
|
||||
{
|
||||
public class ListenerExample {
|
||||
// <code>
|
||||
|
||||
/**
|
||||
*
|
||||
* Listeners are an alternative way of handling events.
|
||||
* I would to suggest to use then when logic of handing event
|
||||
* is more complex
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
showLogo();
|
||||
@@ -55,23 +52,20 @@ public class ListenerExample
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
||||
* Method must meet 2 requirements to be detected
|
||||
* - must have @TikTokEventObserver annotation
|
||||
* - must have 2 parameters
|
||||
* - first parameter must be LiveClient
|
||||
* - second must be class that extending TikTokEvent
|
||||
* - must have 1 parameter of type that extending TikTokEvent
|
||||
*/
|
||||
|
||||
public static class CustomListener implements TikTokEventListener {
|
||||
public static class CustomListener {
|
||||
|
||||
@TikTokEventObserver
|
||||
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
||||
public void onLike(TikTokLikeEvent event) {
|
||||
System.out.println(event.toString());
|
||||
}
|
||||
|
||||
@TikTokEventObserver
|
||||
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
||||
public void onError(TikTokErrorEvent event, LiveClient liveClient) {
|
||||
// event.getException().printStackTrace();
|
||||
}
|
||||
|
||||
@@ -103,8 +97,7 @@ public class ListenerExample
|
||||
}
|
||||
|
||||
// </code>
|
||||
private static void showLogo()
|
||||
{
|
||||
private static void showLogo() {
|
||||
System.out.println(ConsoleColors.GREEN + """
|
||||
|
||||
_____ _ _ _____ _ _ _ \s
|
||||
|
||||
@@ -32,6 +32,7 @@ public class RecorderExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
TikTokLive.newClient("bangbetmenygy")
|
||||
.configure(liveClientSettings ->
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user