File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
src/net/tootallnate/websocket Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 66import java .nio .channels .Selector ;
77import java .nio .channels .ServerSocketChannel ;
88import java .nio .channels .SocketChannel ;
9- import java .security .MessageDigest ;
109import java .security .NoSuchAlgorithmException ;
1110import java .util .Collections ;
12- import java .util .HashMap ;
1311import java .util .Iterator ;
14- import java .util .Properties ;
1512import java .util .Set ;
1613import java .util .concurrent .CopyOnWriteArraySet ;
1714import java .util .concurrent .LinkedBlockingQueue ;
1815
19- import sun .misc .BASE64Encoder ;
20-
2116/**
2217 * <tt>WebSocketServer</tt> is an abstract class that only takes care of the
2318 * HTTP handshake portion of WebSockets. It's up to a subclass to add
@@ -205,13 +200,14 @@ public void run() {
205200 }
206201
207202 while (true ) {
203+ SelectionKey key = null ;
208204 try {
209205 selector .select ();
210206 Set <SelectionKey > keys = selector .selectedKeys ();
211207 Iterator <SelectionKey > i = keys .iterator ();
212208
213209 while (i .hasNext ()) {
214- SelectionKey key = i .next ();
210+ key = i .next ();
215211
216212 // Remove the current key
217213 i .remove ();
@@ -254,6 +250,8 @@ public void run() {
254250 }
255251 }
256252 } catch (IOException ex ) {
253+ if ( key != null )
254+ key .cancel ();
257255 onError (ex );
258256 } catch (RuntimeException ex ) {
259257 ex .printStackTrace ();
You can’t perform that action at this time.
0 commit comments