Simplified discovery of the ServerSession for WebSocket transports.
@@ -263,27 +263,31 @@ public abstract class AbstractWebSocketTransport<S> extends AbstractServerTransp
}
private void processMessages(S wsSession, ServerMessage.Mutable[] messages) throws IOException {
- ServerSessionImpl session = _session;
-
- boolean sendQueue = false;
- boolean sendReplies = false;
- boolean scheduleExpiration = false;
- List<ServerMessage.Mutable> replies = new ArrayList<>(messages.length);
- for (ServerMessage.Mutable message : messages) {
- if (_logger.isDebugEnabled()) {
- _logger.debug("Processing {}", message);
+ if (messages.length == 0) {
+ throw new IOException();
}
+ ServerSessionImpl session = _session;
if (session == null) {
+ ServerMessage.Mutable message = messages[0];
if (Channel.META_HANDSHAKE.equals(message.getChannel())) {
session = getBayeux().newServerSession();
} else if (!_requireHandshakePerConnection) {
_session = session = (ServerSessionImpl)getBayeux().getSession(message.getClientId());
}
- } else if (!session.getId().equals(message.getClientId()) || session.isDisconnected()) {
+ } else if (session.isDisconnected()) {
_session = session = null;
}
+ boolean sendQueue = false;
+ boolean sendReplies = false;
+ boolean scheduleExpiration = false;
+ List<ServerMessage.Mutable> replies = new ArrayList<>(messages.length);
+ for (ServerMessage.Mutable message : messages) {
+ if (_logger.isDebugEnabled()) {
+ _logger.debug("Processing {}", message);
+ }
+
switch (message.getChannel()) {
case Channel.META_HANDSHAKE: {
if (messages.length > 1) {
