mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Including Pinging Task
This commit is contained in:
@@ -30,16 +30,24 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CollectorExample {
|
||||
|
||||
|
||||
private static String mongoUser;
|
||||
|
||||
private static String mongoPassword;
|
||||
|
||||
private static String mongoDatabase;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
var collector = TikTokLiveCollector.use(settings ->
|
||||
{
|
||||
settings.setConnectionUrl("mongodb+srv://jwoln:qaz123456@jwdatabase.a15gw.mongodb.net/?retryWrites=true&w=majority");
|
||||
settings.setConnectionUrl("mongodb+srv://" + mongoUser + ":" + mongoPassword + "@" + mongoDatabase + "/?retryWrites=true&w=majority");
|
||||
settings.setDatabaseName("tiktok");
|
||||
});
|
||||
collector.connectDatabase();
|
||||
|
||||
var users = List.of("tehila_723", "dino123597", "domaxyzx", "dash4214","obserwacje_live");
|
||||
var users = List.of("tehila_723", "dino123597", "domaxyzx", "dash4214", "obserwacje_live");
|
||||
var sessionTag = "Dupa";
|
||||
for (var user : users) {
|
||||
TikTokLive.newClient(user)
|
||||
@@ -51,10 +59,9 @@ public class CollectorExample {
|
||||
{
|
||||
event.getException().printStackTrace();
|
||||
})
|
||||
.addListener(collector.newListener(Map.of("sessionTag", sessionTag),document ->
|
||||
.addListener(collector.newListener(Map.of("sessionTag", sessionTag), document ->
|
||||
{
|
||||
if(document.get("dataType") == "message")
|
||||
{
|
||||
if (document.get("dataType") == "message") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ListenerExample
|
||||
/**
|
||||
*
|
||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
||||
* - must have @TikTokEventHandler annotation
|
||||
* - must have @TikTokEventObserver annotation
|
||||
* - must have 2 parameters
|
||||
* - first parameter must be LiveClient
|
||||
* - second must be class that extending TikTokEvent
|
||||
|
||||
@@ -24,27 +24,34 @@ package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class ProxyExample
|
||||
{
|
||||
public class ProxyExample {
|
||||
public static void main(String[] args) throws Exception {
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings -> {
|
||||
clientSettings.setPrintToConsole(true);
|
||||
clientSettings.getHttpSettings().configureProxy(proxySettings -> {
|
||||
proxySettings.setOnProxyUpdated(proxyData -> System.err.println("Next proxy: " + proxyData.toString()));
|
||||
proxySettings.setType(Proxy.Type.SOCKS);
|
||||
proxySettings.addProxy("localhost", 8080);
|
||||
});
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
liveClient.getLogger().info("Connected "+liveClient.getRoomInfo().getHostName()))
|
||||
.onDisconnected((liveClient, event) ->
|
||||
liveClient.getLogger().info("Disconnect reason: "+event.getReason()))
|
||||
.onLiveEnded((liveClient, event) ->
|
||||
liveClient.getLogger().info("Live Ended"))
|
||||
.onError((liveClient, event) ->
|
||||
event.getException().printStackTrace())
|
||||
.buildAndConnect();
|
||||
.configure(clientSettings -> {
|
||||
clientSettings.setPrintToConsole(true);
|
||||
clientSettings.getHttpSettings().configureProxy(proxySettings -> {
|
||||
proxySettings.setOnProxyUpdated(proxyData -> System.err.println("Next proxy: " + proxyData.toString()));
|
||||
proxySettings.setType(Proxy.Type.SOCKS);
|
||||
proxySettings.addProxy("localhost", 8080);
|
||||
});
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Connected " + liveClient.getRoomInfo().getHostName());
|
||||
})
|
||||
.onDisconnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Disconnect reason: " + event.getReason());
|
||||
})
|
||||
.onLiveEnded((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Live Ended");
|
||||
})
|
||||
.onError((liveClient, event) ->
|
||||
{
|
||||
event.getException().printStackTrace();
|
||||
})
|
||||
.buildAndConnect();
|
||||
System.in.read();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user