Skip to content

Commit a1ef53a

Browse files
committed
further cleanup of the server
1 parent 86b5913 commit a1ef53a

1 file changed

Lines changed: 8 additions & 30 deletions

File tree

src/org/java_websocket/WebSocketServer.java

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.java_websocket;
22

33
import java.io.IOException;
4-
import java.net.InetAddress;
54
import java.net.InetSocketAddress;
65
import java.net.UnknownHostException;
76
import java.nio.ByteBuffer;
@@ -34,7 +33,7 @@ public abstract class WebSocketServer extends WebSocketAdapter implements Runnab
3433
public int DECODERS = Runtime.getRuntime().availableProcessors();
3534

3635
/**
37-
* Holds the list of active_websocktes WebSocket connections. "Active" means WebSocket
36+
* Holds the list of active WebSocket connections. "Active" means WebSocket
3837
* handshake is complete and socket can be written to, or read from.
3938
*/
4039
private final Set<WebSocket> connections = new HashSet<WebSocket>();
@@ -59,18 +58,18 @@ public abstract class WebSocketServer extends WebSocketAdapter implements Runnab
5958
private Thread selectorthread;
6059

6160
private ExecutorService decoders = Executors.newFixedThreadPool( DECODERS );
62-
private ExecutorService flusher = Executors.newSingleThreadExecutor();
61+
// private ExecutorService flusher = Executors.newSingleThreadExecutor();
6362

6463
private Set<WebSocket> active_websocktes = new HashSet<WebSocket>();
65-
private Set<WebSocket> write_demands = new HashSet<WebSocket>();
64+
// private Set<WebSocket> write_demands = new HashSet<WebSocket>();
6665

6766
// CONSTRUCTORS ////////////////////////////////////////////////////////////
6867
/**
6968
* Nullary constructor. Creates a WebSocketServer that will attempt to
7069
* listen on port <var>WebSocket.DEFAULT_PORT</var>.
7170
*/
7271
public WebSocketServer() throws UnknownHostException {
73-
this( new InetSocketAddress( InetAddress.getLocalHost(), WebSocket.DEFAULT_PORT ), null );
72+
this( new InetSocketAddress( WebSocket.DEFAULT_PORT ), null );
7473
}
7574

7675
/**
@@ -100,7 +99,10 @@ public WebSocketServer( InetSocketAddress address , Draft draft ) {
10099

101100
/**
102101
* Starts the server selectorthread that binds to the currently set port number and
103-
* listeners for WebSocket connection requests.
102+
* listeners for WebSocket connection requests. Creates a fixed thread pool with the size {@link WebSocketServer#DECODERS}<br>
103+
* May only be called once.
104+
*
105+
* Alternatively you can call {@link WebSocketServer#run()} directly.
104106
*
105107
* @throws IllegalStateException
106108
*/
@@ -356,28 +358,4 @@ public Boolean call() throws Exception {
356358
return true;
357359
}
358360
}
359-
360-
class WebsocketWriteTask implements Callable<Boolean> {
361-
362-
private WebSocket ws;
363-
364-
private WebsocketWriteTask( WebSocket ws ) {
365-
this.ws = ws;
366-
}
367-
368-
@Override
369-
public Boolean call() throws Exception {
370-
try {
371-
ws.flush();
372-
} catch ( IOException e ) {
373-
handleIOException( ws, e );
374-
} finally {
375-
}
376-
synchronized ( write_demands ) {
377-
write_demands.remove( ws );
378-
}
379-
return true;
380-
}
381-
}
382-
383361
}

0 commit comments

Comments
 (0)