Skip to content

Commit dc2e828

Browse files
authored
Merge pull request TooTallNate#628 from marci4/master
Graceful shutdown on stop()
2 parents c332701 + 069e01b commit dc2e828

File tree

11 files changed

+56
-63
lines changed

11 files changed

+56
-63
lines changed

Jenkinsfile

Lines changed: 0 additions & 30 deletions
This file was deleted.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>org.java-websocket</groupId>
44
<artifactId>Java-WebSocket</artifactId>
55
<packaging>jar</packaging>
6-
<version>1.3.6</version>
6+
<version>1.3.7-dev</version>
77
<name>Java-WebSocket</name>
88
<description>A barebones WebSocket client and server implementation written 100% in Java</description>
99
<url>https://github.com/TooTallNate/Java-WebSocket</url>

project.clj

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/java/org/java_websocket/AbstractWebSocket.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,38 @@ public abstract class AbstractWebSocket extends WebSocketAdapter {
4040

4141
/**
4242
* Attribute which allows you to deactivate the Nagle's algorithm
43+
* @since 1.3.3
4344
*/
4445
private boolean tcpNoDelay;
4546

4647
/**
4748
* Attribute which allows you to enable/disable the SO_REUSEADDR socket option.
49+
* @since 1.3.5
4850
*/
4951
private boolean reuseAddr;
5052

5153
/**
5254
* Attribute for a timer allowing to check for lost connections
55+
* @since 1.3.4
5356
*/
5457
private Timer connectionLostTimer;
5558
/**
5659
* Attribute for a timertask allowing to check for lost connections
60+
* @since 1.3.4
5761
*/
5862
private TimerTask connectionLostTimerTask;
5963

6064
/**
6165
* Attribute for the lost connection check interval
66+
* @since 1.3.4
6267
*/
6368
private int connectionLostTimeout = 60;
6469

6570
/**
6671
* Get the interval checking for lost connections
6772
* Default is 60 seconds
6873
* @return the interval
74+
* @since 1.3.4
6975
*/
7076
public int getConnectionLostTimeout() {
7177
return connectionLostTimeout;
@@ -76,6 +82,7 @@ public int getConnectionLostTimeout() {
7682
* A value lower or equal 0 results in the check to be deactivated
7783
*
7884
* @param connectionLostTimeout the interval in seconds
85+
* @since 1.3.4
7986
*/
8087
public void setConnectionLostTimeout( int connectionLostTimeout ) {
8188
this.connectionLostTimeout = connectionLostTimeout;
@@ -91,6 +98,7 @@ public void setConnectionLostTimeout( int connectionLostTimeout ) {
9198

9299
/**
93100
* Stop the connection lost timer
101+
* @since 1.3.4
94102
*/
95103
protected void stopConnectionLostTimer() {
96104
if (connectionLostTimer != null ||connectionLostTimerTask != null) {
@@ -101,6 +109,7 @@ protected void stopConnectionLostTimer() {
101109
}
102110
/**
103111
* Start the connection lost timer
112+
* @since 1.3.4
104113
*/
105114
protected void startConnectionLostTimer() {
106115
if (this.connectionLostTimeout <= 0) {
@@ -115,6 +124,7 @@ protected void startConnectionLostTimer() {
115124

116125
/**
117126
* This methods allows the reset of the connection lost timer in case of a changed parameter
127+
* @since 1.3.4
118128
*/
119129
private void restartConnectionLostTimer() {
120130
cancelConnectionLostTimer();
@@ -157,11 +167,13 @@ public void run() {
157167
/**
158168
* Getter to get all the currently available connections
159169
* @return the currently available connections
170+
* @since 1.3.4
160171
*/
161172
protected abstract Collection<WebSocket> connections();
162173

163174
/**
164175
* Cancel any running timer for the connection lost detection
176+
* @since 1.3.4
165177
*/
166178
private void cancelConnectionLostTimer() {
167179
if( connectionLostTimer != null ) {
@@ -178,6 +190,7 @@ private void cancelConnectionLostTimer() {
178190
* Tests if TCP_NODELAY is enabled.
179191
*
180192
* @return a boolean indicating whether or not TCP_NODELAY is enabled for new connections.
193+
* @since 1.3.3
181194
*/
182195
public boolean isTcpNoDelay() {
183196
return tcpNoDelay;
@@ -189,6 +202,7 @@ public boolean isTcpNoDelay() {
189202
* Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm) for new connections
190203
*
191204
* @param tcpNoDelay true to enable TCP_NODELAY, false to disable.
205+
* @since 1.3.3
192206
*/
193207
public void setTcpNoDelay( boolean tcpNoDelay ) {
194208
this.tcpNoDelay = tcpNoDelay;
@@ -198,6 +212,7 @@ public void setTcpNoDelay( boolean tcpNoDelay ) {
198212
* Tests Tests if SO_REUSEADDR is enabled.
199213
*
200214
* @return a boolean indicating whether or not SO_REUSEADDR is enabled.
215+
* @since 1.3.5
201216
*/
202217
public boolean isReuseAddr() {
203218
return reuseAddr;
@@ -209,6 +224,7 @@ public boolean isReuseAddr() {
209224
* Enable/disable SO_REUSEADDR for the socket
210225
*
211226
* @param reuseAddr whether to enable or disable SO_REUSEADDR
227+
* @since 1.3.5
212228
*/
213229
public void setReuseAddr( boolean reuseAddr ) {
214230
this.reuseAddr = reuseAddr;

src/main/java/org/java_websocket/drafts/Draft_6455.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class Draft_6455 extends Draft {
9191

9292
/**
9393
* Constructor for the websocket protocol specified by RFC 6455 with default extensions
94+
* @since 1.3.5
9495
*/
9596
public Draft_6455() {
9697
this( Collections.<IExtension>emptyList() );
@@ -100,6 +101,7 @@ public Draft_6455() {
100101
* Constructor for the websocket protocol specified by RFC 6455 with custom extensions
101102
*
102103
* @param inputExtension the extension which should be used for this draft
104+
* @since 1.3.5
103105
*/
104106
public Draft_6455( IExtension inputExtension ) {
105107
this( Collections.singletonList( inputExtension ) );
@@ -109,6 +111,7 @@ public Draft_6455( IExtension inputExtension ) {
109111
* Constructor for the websocket protocol specified by RFC 6455 with custom extensions
110112
*
111113
* @param inputExtensions the extensions which should be used for this draft
114+
* @since 1.3.5
112115
*/
113116
public Draft_6455( List<IExtension> inputExtensions ) {
114117
this( inputExtensions, Collections.<IProtocol>singletonList( new Protocol( "" ) ));
@@ -119,6 +122,8 @@ public Draft_6455( List<IExtension> inputExtensions ) {
119122
*
120123
* @param inputExtensions the extensions which should be used for this draft
121124
* @param inputProtocols the protocols which should be used for this draft
125+
*
126+
* @since 1.3.7
122127
*/
123128
public Draft_6455( List<IExtension> inputExtensions , List<IProtocol> inputProtocols ) {
124129
if (inputExtensions == null || inputProtocols == null) {
@@ -230,6 +235,7 @@ public List<IExtension> getKnownExtensions() {
230235
* Getter for the protocol which is used by this draft
231236
*
232237
* @return the protocol which is used or null, if handshake is not yet done or no valid protocols
238+
* @since 1.3.7
233239
*/
234240
public IProtocol getProtocol() {
235241
return protocol;
@@ -238,6 +244,7 @@ public IProtocol getProtocol() {
238244
/**
239245
* Getter for all available protocols for this draft
240246
* @return the protocols which are enabled for this draft
247+
* @since 1.3.7
241248
*/
242249
public List<IProtocol> getKnownProtocols() {
243250
return knownProtocols;

src/main/java/org/java_websocket/extensions/CompressionExtension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
/**
3535
* Implementation for a compression extension specified by https://tools.ietf.org/html/rfc7692
36+
* @since 1.3.5
3637
*/
3738
public abstract class CompressionExtension extends DefaultExtension {
3839

src/main/java/org/java_websocket/extensions/DefaultExtension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*
3535
* This is a fallback and will always be available for a Draft_6455
3636
*
37+
* @since 1.3.5
3738
*/
3839
public class DefaultExtension implements IExtension {
3940

src/main/java/org/java_websocket/extensions/IExtension.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
/**
3232
* Interface which specifies all required methods to develop a websocket extension.
33+
* @since 1.3.5
3334
*/
3435
public interface IExtension {
3536

@@ -40,6 +41,7 @@ public interface IExtension {
4041
*
4142
* @param inputFrame the frame, which has do be decoded to be used in the application
4243
* @throws InvalidDataException Throw InvalidDataException if the received frame is not correctly implemented by the other endpoint or there are other protocol errors/decoding errors
44+
* @since 1.3.5
4345
*/
4446
void decodeFrame( Framedata inputFrame ) throws InvalidDataException;
4547

@@ -49,6 +51,7 @@ public interface IExtension {
4951
* The resulting frame will be send to the other endpoint.
5052
*
5153
* @param inputFrame the frame, which has do be encoded to be used on the other endpoint
54+
* @since 1.3.5
5255
*/
5356
void encodeFrame( Framedata inputFrame );
5457

@@ -57,6 +60,7 @@ public interface IExtension {
5760
*
5861
* @param inputExtensionHeader the received Sec-WebSocket-Extensions header field offered by the other endpoint
5962
* @return true, if the offer does fit to this specific extension
63+
* @since 1.3.5
6064
*/
6165
boolean acceptProvidedExtensionAsServer( String inputExtensionHeader );
6266

@@ -65,6 +69,7 @@ public interface IExtension {
6569
*
6670
* @param inputExtensionHeader the received Sec-WebSocket-Extensions header field offered by the other endpoint
6771
* @return true, if the offer does fit to this specific extension
72+
* @since 1.3.5
6873
*/
6974
boolean acceptProvidedExtensionAsClient( String inputExtensionHeader );
7075

@@ -73,6 +78,7 @@ public interface IExtension {
7378
*
7479
* @param inputFrame the received frame
7580
* @throws InvalidDataException Throw InvalidDataException if the received frame is not correctly implementing the specification for the specific extension
81+
* @since 1.3.5
7682
*/
7783
void isFrameValid( Framedata inputFrame ) throws InvalidDataException;
7884

@@ -81,6 +87,7 @@ public interface IExtension {
8187
* If the extension returns an empty string (""), the offer will not be included in the handshake.
8288
*
8389
* @return the specific Sec-WebSocket-Extensions header for this extension
90+
* @since 1.3.5
8491
*/
8592
String getProvidedExtensionAsClient();
8693

@@ -89,25 +96,29 @@ public interface IExtension {
8996
* If the extension returns an empty string (""), the offer will not be included in the handshake.
9097
*
9198
* @return the specific Sec-WebSocket-Extensions header for this extension
99+
* @since 1.3.5
92100
*/
93101
String getProvidedExtensionAsServer();
94102

95103
/**
96104
* Extensions must only be by one websocket at all. To prevent extensions to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given extension instance.<br>
97105
* The copy can be safely used in conjunction with a new websocket connection.
98106
* @return a copy of the extension
107+
* @since 1.3.5
99108
*/
100109
IExtension copyInstance();
101110

102111
/**
103112
* Cleaning up internal stats when the draft gets reset.
113+
* @since 1.3.5
104114
*/
105115
void reset();
106116

107117
/**
108118
* Return a string which should contain the class name as well as additional information about the current configurations for this extension (DEBUG purposes)
109119
*
110120
* @return a string containing the class name as well as additional information
121+
* @since 1.3.5
111122
*/
112123
String toString();
113124
}

src/main/java/org/java_websocket/protocols/IProtocol.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
/**
2929
* Interface which specifies all required methods for a Sec-WebSocket-Protocol
30+
*
31+
* @since 1.3.7
3032
*/
3133
public interface IProtocol {
3234

@@ -35,6 +37,7 @@ public interface IProtocol {
3537
*
3638
* @param inputProtocolHeader the received Sec-WebSocket-Protocol header field offered by the other endpoint
3739
* @return true, if the offer does fit to this specific protocol
40+
* @since 1.3.7
3841
*/
3942
boolean acceptProvidedProtocol( String inputProtocolHeader );
4043

@@ -43,19 +46,22 @@ public interface IProtocol {
4346
* If the extension returns an empty string (""), the offer will not be included in the handshake.
4447
*
4548
* @return the specific Sec-WebSocket-Protocol header for this protocol
49+
* @since 1.3.7
4650
*/
4751
String getProvidedProtocol();
4852

4953
/**
5054
* To prevent protocols to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given protocol instance.
5155
* @return a copy of the protocol
56+
* @since 1.3.7
5257
*/
5358
IProtocol copyInstance();
5459

5560
/**
5661
* Return a string which should contain the protocol name as well as additional information about the current configurations for this protocol (DEBUG purposes)
5762
*
5863
* @return a string containing the protocol name as well as additional information
64+
* @since 1.3.7
5965
*/
6066
String toString();
6167
}

src/main/java/org/java_websocket/protocols/Protocol.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
/**
2929
* Class which represents the protocol used as Sec-WebSocket-Protocol
30+
*
31+
* @since 1.3.7
3032
*/
3133
public class Protocol implements IProtocol {
3234

0 commit comments

Comments
 (0)