aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-23 16:53:47 +0300
committerGravatar Vitaly Takmazov2018-04-23 16:53:47 +0300
commit100d52a7bf6887b2f8af2fc816041d09553c3617 (patch)
tree9c0333e907edca708c014f2e43e66215b1e8a7c4
parentde22e88e68bdcdb427d079f835cc4fae8cacd0dd (diff)
server: ConcurrentWebSocketSessionDecorator
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java5
-rw-r--r--juick-server/src/main/java/com/juick/server/WebsocketManager.java6
2 files changed, 6 insertions, 5 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java
index 439c4bd7..9f62fd4d 100644
--- a/juick-notifications/src/main/java/com/juick/components/Notifications.java
+++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java
@@ -46,6 +46,7 @@ import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.PingMessage;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
+import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import javax.annotation.Nonnull;
@@ -261,13 +262,13 @@ public class Notifications extends TextWebSocketHandler implements NotificationC
@Inject
private ApplicationEventPublisher applicationEventPublisher;
- private WebSocketSession session;
+ private ConcurrentWebSocketSessionDecorator session;
private final AtomicBoolean closeFlag = new AtomicBoolean(false);
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
logger.info("WebSocket connected");
- this.session = session;
+ this.session = new ConcurrentWebSocketSessionDecorator(session, 60000, 65535);
}
@Override
diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
index c43e191c..fdee5065 100644
--- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java
+++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
@@ -25,7 +25,6 @@ import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.HttpForbiddenException;
import com.juick.server.util.HttpNotFoundException;
import com.juick.service.MessagesService;
-import com.juick.service.SubscriptionService;
import com.juick.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -39,6 +38,7 @@ import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.PingMessage;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
+import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@@ -177,7 +177,7 @@ public class WebsocketManager extends TextWebSocketHandler {
}
class SocketSubscribed {
- WebSocketSession session;
+ ConcurrentWebSocketSessionDecorator session;
String clientName;
User visitor;
int MID;
@@ -188,7 +188,7 @@ public class WebsocketManager extends TextWebSocketHandler {
boolean legacy;
public SocketSubscribed(WebSocketSession session, String clientName, User visitor, boolean legacy) {
- this.session = session;
+ this.session = new ConcurrentWebSocketSessionDecorator(session, 60000, 65536);
this.clientName = clientName;
this.visitor = visitor;
tsConnected = tsLastData = System.currentTimeMillis();