All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.linyuzai.connection.loadbalance.sse.servlet.ServletSubscriberSseConnection Maven / Gradle / Ivy

The newest version!
package com.github.linyuzai.connection.loadbalance.sse.servlet;

import com.github.linyuzai.connection.loadbalance.sse.concept.SubscriberSseConnection;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

import java.net.HttpURLConnection;
import java.util.function.Consumer;

@Getter
@Setter
@RequiredArgsConstructor
public class ServletSubscriberSseConnection extends SubscriberSseConnection {

    private HttpURLConnection http;

    @Override
    public void doClose(Object reason, Runnable onSuccess, Consumer onError, Runnable onComplete) {
        try {
            if (http != null) {
                http.disconnect();
            }
            onSuccess.run();
        } catch (Throwable e) {
            onError.accept(e);
        } finally {
            onComplete.run();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy