Skip to content

Commit f45ed99

Browse files
committed
Move all source files into the "net.tootallnate.websocket" package. Make 'WebSocket' public, but constructor protected, since instances must be exposed through 'WebSocketServer', and therefore must be included in the JavaDoc. Slight doc improvements.
1 parent 4f702ab commit f45ed99

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/WebSocket.java renamed to src/net/tootallnate/websocket/WebSocket.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package net.tootallnate.websocket;
12

23
import java.io.IOException;
34
import java.nio.ByteBuffer;
@@ -13,10 +14,12 @@
1314
*
1415
* This is an inner class, used by <tt>WebSocketClient</tt> and
1516
* <tt>WebSocketServer</tt>, and should never need to be instantiated directly
16-
* by your code.
17+
* by your code. However, instances are exposed in <tt>WebSocketServer</tt>
18+
* through the <i>onClientOpen</i>, <i>onClientClose</i>,
19+
* <i>onClientMessage</i> callbacks.
1720
* @author Nathan Rajlich
1821
*/
19-
final class WebSocket {
22+
public final class WebSocket {
2023
// CONSTANTS ///////////////////////////////////////////////////////////////
2124
/**
2225
* The default port of WebSockets, as defined in the spec. If the nullary
@@ -84,22 +87,21 @@ final class WebSocket {
8487
* @param listener The {@link WebSocketListener} to notify of events when
8588
* they occur.
8689
*/
87-
public WebSocket(SocketChannel socketChannel, WebSocketListener listener) {
90+
WebSocket(SocketChannel socketChannel, WebSocketListener listener) {
8891
this.socketChannel = socketChannel;
8992
this.handshakeComplete = false;
9093
this.remoteHandshake = this.currentFrame = null;
9194
this.buffer = ByteBuffer.allocate(1);
9295
this.wsl = listener;
9396
}
9497

95-
// PUBLIC INSTANCE METHODS /////////////////////////////////////////////////
9698
/**
9799
* Should be called when a Selector has a key that is writable for this
98100
* WebSocket's SocketChannel connection.
99101
* @throws IOException When socket related I/O errors occur.
100102
* @throws NoSuchAlgorithmException
101103
*/
102-
public void handleRead() throws IOException, NoSuchAlgorithmException {
104+
void handleRead() throws IOException, NoSuchAlgorithmException {
103105
this.buffer.rewind();
104106

105107
int bytesRead = -1;
@@ -120,6 +122,7 @@ public void handleRead() throws IOException, NoSuchAlgorithmException {
120122
}
121123
}
122124

125+
// PUBLIC INSTANCE METHODS /////////////////////////////////////////////////
123126
/**
124127
* Closes the underlying SocketChannel, and calls the listener's onClose
125128
* event handler.

src/WebSocketClient.java renamed to src/net/tootallnate/websocket/WebSocketClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package net.tootallnate.websocket;
12

23
import java.io.IOException;
34
import java.net.InetSocketAddress;

src/WebSocketListener.java renamed to src/net/tootallnate/websocket/WebSocketListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package net.tootallnate.websocket;
12

23
import java.io.IOException;
34
import java.security.NoSuchAlgorithmException;

src/WebSocketServer.java renamed to src/net/tootallnate/websocket/WebSocketServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package net.tootallnate.websocket;
12

23
import java.io.IOException;
34
import java.nio.ByteBuffer;

0 commit comments

Comments
 (0)