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

com.github.sseserver.remote.ClusterConnectionService Maven / Gradle / Ivy

There is a newer version: 1.2.19
Show newest version
package com.github.sseserver.remote;

import com.github.sseserver.ConnectionQueryService;
import com.github.sseserver.SendService;
import com.github.sseserver.local.LocalConnectionService;
import com.github.sseserver.springboot.SseServerProperties;
import com.github.sseserver.util.ReferenceCounted;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;

public interface ClusterConnectionService extends ConnectionQueryService, SendService> {

    static ClusterConnectionService newInstance(Supplier localSupplier,
                                                Supplier>> remoteSupplier,
                                                boolean primary) {
        return new ClusterConnectionServiceImpl(localSupplier, remoteSupplier, primary);
    }

    boolean isPrimary();

    /* getUsers */

     ClusterCompletableFuture, ClusterConnectionService> getUsersAsync(SseServerProperties.AutoType autoType);

     ClusterCompletableFuture getUserAsync(Serializable userId);

     ClusterCompletableFuture, ClusterConnectionService> getUsersAsync();

     ClusterCompletableFuture, ClusterConnectionService> getUsersByListeningAsync(String sseListenerName);

     ClusterCompletableFuture, ClusterConnectionService> getUsersByTenantIdListeningAsync(Serializable tenantId, String sseListenerName);

    /* getUserIds */

     ClusterCompletableFuture, ClusterConnectionService> getUserIdsAsync(Class type);

     ClusterCompletableFuture, ClusterConnectionService> getUserIdsByListeningAsync(String sseListenerName, Class type);

     ClusterCompletableFuture, ClusterConnectionService> getUserIdsByTenantIdListeningAsync(Serializable tenantId, String sseListenerName, Class type);

    /* getConnection */

     ClusterCompletableFuture>, ClusterConnectionService> getConnectionDTOAllAsync(SseServerProperties.AutoType autoType);

    ClusterCompletableFuture, ClusterConnectionService> getConnectionDTOByUserIdAsync(Serializable userId);

    /* disconnect */

    ClusterCompletableFuture disconnectByUserId(Serializable userId);

    ClusterCompletableFuture disconnectByAccessToken(String accessToken);

    ClusterCompletableFuture disconnectByConnectionId(Long connectionId);

    ClusterCompletableFuture disconnectByConnectionId(Long connectionId, Long duration, Long sessionDuration);

    ClusterCompletableFuture disconnectByConnectionIds(Collection connectionIds);

    /**
     * 清零已统计的在线时长
     *
     * @param userId 用户ID
     * @return 清空的链接
     */
    default ClusterCompletableFuture clearDurationByUserId(Serializable userId) {
        return setDurationByUserId(userId, 0L);
    }

    default ClusterCompletableFuture clearDurationByAccessToken(String accessToken) {
        return setDurationByAccessToken(accessToken, 0L);
    }

    /**
     * 修改已统计的在线时长
     *
     * @param userId         用户ID
     * @param durationSecond 在线时长(秒)
     * @return 修改的链接
     */
    ClusterCompletableFuture setDurationByUserId(Serializable userId, long durationSecond);

    ClusterCompletableFuture setDurationByAccessToken(String accessToken, long durationSecond);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy