diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java index 017708b5c4..a3a5d650dd 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java @@ -17,11 +17,21 @@ package io.cloudbeaver.server.jobs; import io.cloudbeaver.model.session.BaseWebSession; +import io.cloudbeaver.model.session.WebSession; +import io.cloudbeaver.server.CBApplication; import io.cloudbeaver.server.CBPlatform; +import org.jkiss.dbeaver.model.DBPDataSource; +import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.app.DBPPlatform; +import org.jkiss.dbeaver.model.auth.SMSession; +import org.jkiss.dbeaver.model.websocket.event.WSEventType; +import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceEvent; +import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceProperty; +import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.dbeaver.runtime.jobs.DataSourceMonitorJob; import java.util.Collection; +import java.util.List; /** * Web data source monitor job. @@ -35,8 +45,23 @@ public WebDataSourceMonitorJob(DBPPlatform platform) { @Override protected void doJob() { Collection allSessions = CBPlatform.getInstance().getSessionManager().getAllActiveSessions(); - allSessions.parallelStream().forEach( - s -> checkDataSourceAliveInWorkspace(s.getWorkspace()) - ); + allSessions.parallelStream().forEach(s -> { + checkDataSourceAliveInWorkspace(s.getWorkspace(), s::getLastAccessTimeMillis); + }); + + } + + @Override + public void showNotification(DBPDataSource dataSource, DBPDataSourceContainer dsDescriptor, SMSession smSession) { + if (smSession instanceof WebSession webSession) { + webSession.addSessionEvent( //TODO: Add new event for disconnect datasource + WSDataSourceEvent.update( + webSession.getSessionId(), + webSession.getUserId(), + dsDescriptor.getProject().getId(), + List.of(dsDescriptor.getId()), + WSDataSourceProperty.CONFIGURATION) + ); + } } }