forked from github/dataease
Merge branch 'dev' of github.com:dataease/dataease into dev
This commit is contained in:
commit
b9847a2c4a
@ -6,6 +6,8 @@ import org.springframework.web.socket.WebSocketHandler;
|
|||||||
import org.springframework.web.socket.WebSocketSession;
|
import org.springframework.web.socket.WebSocketSession;
|
||||||
import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
|
import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class DeWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
|
public class DeWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
|
||||||
|
|
||||||
|
|
||||||
@ -16,17 +18,22 @@ public class DeWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||||
String name = session.getPrincipal().getName();
|
Optional.ofNullable(session.getPrincipal()).ifPresent(principal -> {
|
||||||
Long userId = Long.parseLong(name);
|
String name = principal.getName();
|
||||||
WsUtil.onLine(userId);
|
Long userId = Long.parseLong(name);
|
||||||
|
WsUtil.onLine(userId);
|
||||||
|
});
|
||||||
super.afterConnectionEstablished(session);
|
super.afterConnectionEstablished(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
||||||
String name = session.getPrincipal().getName();
|
Optional.ofNullable(session.getPrincipal()).ifPresent(principal -> {
|
||||||
Long userId = Long.parseLong(name);
|
String name = principal.getName();
|
||||||
WsUtil.offLine(userId);
|
Long userId = Long.parseLong(name);
|
||||||
|
WsUtil.offLine(userId);
|
||||||
|
});
|
||||||
|
|
||||||
super.afterConnectionClosed(session, closeStatus);
|
super.afterConnectionClosed(session, closeStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user