com.github.sseserver.remote.ClusterConnectionService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sse-server Show documentation
Show all versions of sse-server Show documentation
Sse server for Spring Boot
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);
}