|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -59,6 +59,7 @@ import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSe |
|
|
|
* sub-protocol handler to send messages from the application back to the client. |
|
|
|
* sub-protocol handler to send messages from the application back to the client. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Andy Wilkinson |
|
|
|
* @author Andy Wilkinson |
|
|
|
* @author Artem Bilan |
|
|
|
* @author Artem Bilan |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
@ -150,8 +151,8 @@ public class SubProtocolWebSocketHandler |
|
|
|
for (String protocol : protocols) { |
|
|
|
for (String protocol : protocols) { |
|
|
|
SubProtocolHandler replaced = this.protocolHandlerLookup.put(protocol, handler); |
|
|
|
SubProtocolHandler replaced = this.protocolHandlerLookup.put(protocol, handler); |
|
|
|
if (replaced != null && replaced != handler) { |
|
|
|
if (replaced != null && replaced != handler) { |
|
|
|
throw new IllegalStateException("Can't map " + handler + |
|
|
|
throw new IllegalStateException("Cannot map " + handler + |
|
|
|
" to protocol '" + protocol + "'. Already mapped to " + replaced + "."); |
|
|
|
" to protocol '" + protocol + "': already mapped to " + replaced + "."); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.protocolHandlers.add(handler); |
|
|
|
this.protocolHandlers.add(handler); |
|
|
|
@ -257,8 +258,8 @@ public class SubProtocolWebSocketHandler |
|
|
|
holder.getSession().close(CloseStatus.GOING_AWAY); |
|
|
|
holder.getSession().close(CloseStatus.GOING_AWAY); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable ex) { |
|
|
|
catch (Throwable ex) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isWarnEnabled()) { |
|
|
|
logger.error("Failed to close '" + holder.getSession() + "': " + ex); |
|
|
|
logger.warn("Failed to close '" + holder.getSession() + "': " + ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -318,7 +319,7 @@ public class SubProtocolWebSocketHandler |
|
|
|
String sessionId = resolveSessionId(message); |
|
|
|
String sessionId = resolveSessionId(message); |
|
|
|
if (sessionId == null) { |
|
|
|
if (sessionId == null) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
logger.error("Couldn't find session id in " + message); |
|
|
|
logger.error("Could not find session id in " + message); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -397,8 +398,8 @@ public class SubProtocolWebSocketHandler |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
catch (Exception ex) { |
|
|
|
// Shouldn't happen
|
|
|
|
// Shouldn't happen
|
|
|
|
logger.error("Failed to obtain session.getAcceptedProtocol(). " + |
|
|
|
logger.error("Failed to obtain session.getAcceptedProtocol(): " + |
|
|
|
"Will use the default protocol handler (if configured).", ex); |
|
|
|
"will use the default protocol handler (if configured).", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SubProtocolHandler handler; |
|
|
|
SubProtocolHandler handler; |
|
|
|
@ -465,8 +466,8 @@ public class SubProtocolWebSocketHandler |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
WebSocketSession session = holder.getSession(); |
|
|
|
WebSocketSession session = holder.getSession(); |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isInfoEnabled()) { |
|
|
|
logger.error("No messages received after " + timeSinceCreated + " ms. " + |
|
|
|
logger.info("No messages received after " + timeSinceCreated + " ms. " + |
|
|
|
"Closing " + holder.getSession() + "."); |
|
|
|
"Closing " + holder.getSession() + "."); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -474,8 +475,8 @@ public class SubProtocolWebSocketHandler |
|
|
|
session.close(CloseStatus.SESSION_NOT_RELIABLE); |
|
|
|
session.close(CloseStatus.SESSION_NOT_RELIABLE); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable ex) { |
|
|
|
catch (Throwable ex) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isWarnEnabled()) { |
|
|
|
logger.error("Failure while closing " + session, ex); |
|
|
|
logger.warn("Failed to close unreliable " + session, ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|