mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Improvement of Listener
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package io.github.jwdeveloper.tiktok.annotations;
|
||||
/**
|
||||
* HIGHEST 1
|
||||
* HIGH 2
|
||||
* NORMAL 3
|
||||
* LOW 4
|
||||
* LOWEST 5
|
||||
*/
|
||||
|
||||
public enum Priority {
|
||||
LOWEST(2), LOW(1), NORMAL(0), HIGH(-1), HIGHEST(-2);
|
||||
|
||||
public int priorityValue;
|
||||
|
||||
Priority(int value) {
|
||||
this.priorityValue = value;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,13 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TikTokEventObserver
|
||||
{
|
||||
public @interface TikTokEventObserver {
|
||||
|
||||
Priority priority() default Priority.NORMAL;
|
||||
|
||||
/**
|
||||
* when true, action is invoked on the another thread
|
||||
* @return
|
||||
*/
|
||||
boolean async();
|
||||
}
|
||||
|
||||
@@ -27,14 +27,13 @@ import java.util.List;
|
||||
/**
|
||||
* You can dynamically add or removing TikTokEventListener
|
||||
*
|
||||
* @see TikTokEventListener
|
||||
*
|
||||
*/
|
||||
public interface ListenersManager
|
||||
{
|
||||
List<TikTokEventListener> getListeners();
|
||||
List<Object> getListeners();
|
||||
|
||||
void addListener(TikTokEventListener listener);
|
||||
void addListener(Object listener);
|
||||
|
||||
void removeListener(TikTokEventListener listener);
|
||||
void removeListener(Object listener);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
* {@code
|
||||
* public static class CustomListener implements TikTokEventListener
|
||||
* {
|
||||
* @TikTokEventObserver
|
||||
* @TikTokEventObserver
|
||||
* public void onError(LiveClient liveClient, TikTokErrorEvent event)
|
||||
* {
|
||||
* System.out.println(event.getException().getMessage());
|
||||
@@ -67,7 +67,9 @@ import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public interface TikTokEventListener
|
||||
{
|
||||
//TODO I think this interface can be removed, since we are using,
|
||||
//annotation @TikTokEventHandler to check methods that are events
|
||||
@Deprecated(forRemoval = true, since = "This interface is not longer needed, please remove it from your class")
|
||||
public interface TikTokEventListener {
|
||||
|
||||
}
|
||||
@@ -54,12 +54,11 @@ public interface LiveClientBuilder extends EventsBuilder<LiveClientBuilder> {
|
||||
LiveClientBuilder configure(Consumer<LiveClientSettings> onConfigure);
|
||||
|
||||
/**
|
||||
* @see TikTokEventListener
|
||||
* Adding events listener class, its fancy way to register events without using lamda method
|
||||
* but actual method in class that implements TikTokEventListener
|
||||
* @return
|
||||
*/
|
||||
LiveClientBuilder addListener(TikTokEventListener listener);
|
||||
LiveClientBuilder addListener(Object listener);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,9 +24,8 @@ package io.github.jwdeveloper.tiktok.websocket;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.requests.LiveConnectionData;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||
|
||||
public interface SocketClient {
|
||||
public interface LiveSocketClient {
|
||||
void start(LiveConnectionData.Response webcastResponse, LiveClient tikTokLiveClient);
|
||||
void stop();
|
||||
}
|
||||
Reference in New Issue
Block a user