Skip to content

Commit e56559f

Browse files
committed
WebSocketSession extends java.io.Closeable, plus reorganization of AbstractSockJsSession's code
Issue: SPR-12311
1 parent da14aee commit e56559f

File tree

2 files changed

+169
-161
lines changed

2 files changed

+169
-161
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/WebSocketSession.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.web.socket;
1818

19+
import java.io.Closeable;
1920
import java.io.IOException;
2021
import java.net.InetSocketAddress;
2122
import java.net.URI;
@@ -32,7 +33,7 @@
3233
* @author Rossen Stoyanchev
3334
* @since 4.0
3435
*/
35-
public interface WebSocketSession {
36+
public interface WebSocketSession extends Closeable {
3637

3738
/**
3839
* Return a unique session identifier.
@@ -51,12 +52,10 @@ public interface WebSocketSession {
5152

5253
/**
5354
* Return the map with attributes associated with the WebSocket session.
54-
*
5555
* <p>When the WebSocketSession is created, on the server side, the map can be
5656
* through a {@link org.springframework.web.socket.server.HandshakeInterceptor}.
5757
* On the client side, the map can be populated by passing attributes to the
58-
* {@link org.springframework.web.socket.client.WebSocketClient} handshake
59-
* methods.
58+
* {@link org.springframework.web.socket.client.WebSocketClient} handshake methods.
6059
*/
6160
Map<String, Object> getAttributes();
6261

@@ -110,22 +109,22 @@ public interface WebSocketSession {
110109
List<WebSocketExtension> getExtensions();
111110

112111
/**
113-
* Return whether the connection is still open.
112+
* Send a WebSocket message: either {@link TextMessage} or {@link BinaryMessage}.
114113
*/
115-
boolean isOpen();
114+
void sendMessage(WebSocketMessage<?> message) throws IOException;
116115

117116
/**
118-
* Send a WebSocket message either {@link TextMessage} or
119-
* {@link BinaryMessage}.
117+
* Return whether the connection is still open.
120118
*/
121-
void sendMessage(WebSocketMessage<?> message) throws IOException;
119+
boolean isOpen();
122120

123121
/**
124122
* Close the WebSocket connection with status 1000, i.e. equivalent to:
125123
* <pre class="code">
126124
* session.close(CloseStatus.NORMAL);
127125
* </pre>
128126
*/
127+
@Override
129128
void close() throws IOException;
130129

131130
/**

0 commit comments

Comments
 (0)