28 lines
900 B
Java
28 lines
900 B
Java
package io.wdd.pusher.example;
|
|
|
|
|
|
import io.wdd.pusher.core.exception.NtfyStreamingException;
|
|
import io.wdd.pusher.core.model.StreamRequest;
|
|
import io.wdd.pusher.core.stream.StreamingService;
|
|
|
|
public class StreamingExample {
|
|
public static void main(String[] args) throws NtfyStreamingException {
|
|
|
|
StreamRequest request = new StreamRequest();
|
|
request.setHost("ntfy.sh");
|
|
request.setTopic("test_ntfy2");
|
|
|
|
StreamingService streamingConnection = new StreamingService(request);
|
|
streamingConnection.setDataListener(data -> {
|
|
// Process the incoming data here
|
|
System.out.println("Received data: " + data);
|
|
});
|
|
|
|
// Start the streaming connection
|
|
streamingConnection.start();
|
|
|
|
// Keep the connection open and receive data indefinitely
|
|
// To stop the connection, call streamingConnection.stop()
|
|
}
|
|
}
|