| 1234567891011121314151617181920212223242526272829303132333435 |
- package com.its.pis.websocket;
- import lombok.Data;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.socket.TextMessage;
- import org.springframework.web.socket.WebSocketSession;
- import java.io.IOException;
- @Slf4j
- @Data
- public class ItsWebSocketSession {
- private ItsWebSocketHandler itsWebsocketHandler;
- private WebSocketSession session;
- private String groupId;
- public ItsWebSocketSession(ItsWebSocketHandler itsWebsocketHandler, org.springframework.web.socket.WebSocketSession session) {
- this.itsWebsocketHandler = itsWebsocketHandler;
- this.session = session;
- }
- public void sendMessage(String command, TextMessage message) {
- if (this.session != null && this.session.isOpen()) {
- synchronized (this.session) {
- try {
- this.session.sendMessage(message);
- } catch (IOException e) {
- log.error("sendMessage: nodeId: {}, session: {}", command, session);
- }
- }
- }
- }
- }
|