diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/annotations/OnWebSocketBinary.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/annotations/OnWebSocketBinary.java deleted file mode 100644 index fdc795af018..00000000000 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/annotations/OnWebSocketBinary.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.eclipse.jetty.websocket.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.nio.ByteBuffer; - -import org.eclipse.jetty.websocket.api.WebSocketConnection; - -/** - * Annotation for tagging methods to receive Binary message events. - *
- * Acceptable method patterns.
- * Note: methodName
can be any name you want to use.
- *
public void methodName(byte payload[], int offset, int length)
public void methodName({@link ByteBuffer} payload)
public void methodName({@link WebSocketConnection} conn, byte payload[], int offset, int length)
public void methodName({@link WebSocketConnection} conn, {@link ByteBuffer} payload)
* Acceptable method patterns.
* Note: methodName
can be any name you want to use.
+ *
+ * Text Message Versions *
public void methodName(String text)
public void methodName({@link WebSocketConnection} conn, String text)
public void methodName(Reader reader)
public void methodName({@link WebSocketConnection} conn, Reader reader)
+ * Binary Message Versions + *
public void methodName(byte buf[], int offset, int length)
public void methodName({@link WebSocketConnection} conn, byte buf[], int offset, int length)
public void methodName(InputStream stream)
public void methodName({@link WebSocketConnection} conn, InputStream stream)
- * Acceptable method patterns.
- * Note: methodName
can be any name you want to use.
- *
public void methodName(String text)
public void methodName({@link WebSocketConnection} conn, String text)
+ * This is an end-user accessible class. + */ +public class WebSocketBlockingConnection +{ + private final RawConnection conn; + private final ByteBufferPool bufferPool; + private final WebSocketPolicy policy; + private final Generator generator; + + public WebSocketBlockingConnection(WebSocketConnection conn) + { + if (conn instanceof RawConnection) + { + this.conn = (RawConnection)conn; + } + else + { + throw new IllegalArgumentException("Unsupported implementation of WebSocketConnection"); + } + this.bufferPool = this.conn.getBufferPool(); + this.policy = conn.getPolicy(); + this.generator = new Generator(this.policy); + } + + /** + * Send a binary message. + *
+ * Basic usage, results in a blocking write.
+ */
+ public void write(byte[] data, int offset, int length) throws IOException
+ {
+ BinaryFrame frame = new BinaryFrame(data,offset,length);
+ ByteBuffer buf = bufferPool.acquire(policy.getBufferSize(),false);
+ try
+ {
+ generator.generate(buf,frame);
+ FutureCallback
+ * Basic usage, results in a blocking write.
+ */
+ public void write(String message) throws IOException
+ {
+ TextFrame frame = new TextFrame(message);
+ ByteBuffer buf = bufferPool.acquire(policy.getBufferSize(),false);
+ try
+ {
+ generator.generate(buf,frame);
+ FutureCallback
@@ -281,4 +288,10 @@ public class WebSocketAsyncConnection extends AbstractAsyncConnection implements
}
// TODO write(context,callback,frames);
}
+
+ @Override
+ public
- * Basic usage, results in a blocking write.
- */
- public void write(byte[] data, int offset, int length) throws IOException
- {
-
- }
-
- /**
- * Send a series of binary messages.
- *
- * Note: each buffer results in its own binary message frame.
- *
- * Basic usage, results in a series of blocking writes.
- */
- public void write(ByteBuffer... buffers) throws IOException
- {
-
- }
-
- /**
- * Send text messages.
- *
- * Basic usage, results in a series of blocking writes.
- */
- public void write(String... messages) throws IOException
- {
-
- }
-}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadBinarySignatureSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadBinarySignatureSocket.java
index b79ca87f5ee..430981b3e07 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadBinarySignatureSocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadBinarySignatureSocket.java
@@ -1,17 +1,18 @@
package org.eclipse.jetty.websocket.annotations;
-import java.nio.ByteBuffer;
-
import org.eclipse.jetty.websocket.api.WebSocketConnection;
+/**
+ * Invalid Socket: Annotate a message interest on a method with a return type.
+ */
@WebSocket
public class BadBinarySignatureSocket
{
/**
* Declaring a non-void return type
*/
- @OnWebSocketBinary
- public boolean onBinary(WebSocketConnection conn, ByteBuffer payload)
+ @OnWebSocketMessage
+ public boolean onBinary(WebSocketConnection conn, byte buf[], int offset, int len)
{
return false;
}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadDuplicateBinarySocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadDuplicateBinarySocket.java
index 2f7e89aecb4..6a7cfcc0096 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadDuplicateBinarySocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadDuplicateBinarySocket.java
@@ -1,14 +1,17 @@
package org.eclipse.jetty.websocket.annotations;
-import java.nio.ByteBuffer;
+import java.io.InputStream;
+/**
+ * Invalid Socket: Annotate 2 methods with interest in Binary Messages.
+ */
@WebSocket
public class BadDuplicateBinarySocket
{
/**
* First method
*/
- @OnWebSocketBinary
+ @OnWebSocketMessage
public void binMe(byte[] payload, int offset, int len)
{
/* ignore */
@@ -17,8 +20,8 @@ public class BadDuplicateBinarySocket
/**
* Second method
*/
- @OnWebSocketBinary
- public void binMe(ByteBuffer payload)
+ @OnWebSocketMessage
+ public void streamMe(InputStream stream)
{
/* ignore */
}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadTextSignatureSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadTextSignatureSocket.java
index 3cd1a3c5d06..bf74f42948f 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadTextSignatureSocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/BadTextSignatureSocket.java
@@ -2,13 +2,16 @@ package org.eclipse.jetty.websocket.annotations;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
+/**
+ * Invalid Socket: Annotate a message interest on a static method
+ */
@WebSocket
public class BadTextSignatureSocket
{
/**
* Declaring a static method
*/
- @OnWebSocketText
+ @OnWebSocketMessage
public static void onText(WebSocketConnection conn, String text)
{
/* do nothing */
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyEchoSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyEchoSocket.java
index c9c4d90c093..45fb4bcf98f 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyEchoSocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyEchoSocket.java
@@ -2,8 +2,8 @@ package org.eclipse.jetty.websocket.annotations;
import java.io.IOException;
+import org.eclipse.jetty.websocket.api.WebSocketBlockingConnection;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
-import org.eclipse.jetty.websocket.io.WebSocketBlockingConnection;
/**
* The most common websocket implementation.
@@ -34,7 +34,7 @@ public class MyEchoSocket
this.blocking = new WebSocketBlockingConnection(conn);
}
- @OnWebSocketText
+ @OnWebSocketMessage
public void onText(String message)
{
if (conn == null)
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyStatelessEchoSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyStatelessEchoSocket.java
index 411334633a3..ec619c74860 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyStatelessEchoSocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/annotations/MyStatelessEchoSocket.java
@@ -16,7 +16,7 @@ import org.eclipse.jetty.websocket.api.WebSocketConnection;
@WebSocket
public class MyStatelessEchoSocket
{
- @OnWebSocketText
+ @OnWebSocketMessage
public void onText(WebSocketConnection conn, String text)
{
try
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/EventMethodsCacheTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/EventMethodsCacheTest.java
index 41d168ed63f..6eea6a28442 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/EventMethodsCacheTest.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/EventMethodsCacheTest.java
@@ -15,8 +15,6 @@ import org.eclipse.jetty.websocket.annotations.NotASocket;
import org.eclipse.jetty.websocket.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.samples.AdapterConnectCloseSocket;
import org.eclipse.jetty.websocket.api.samples.ListenerBasicSocket;
-import org.eclipse.jetty.websocket.frames.BaseFrame;
-import org.eclipse.jetty.websocket.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@@ -57,7 +55,8 @@ public class EventMethodsCacheTest
assertHasEventMethod(classId + ".onException",methods.onException);
assertHasEventMethod(classId + ".onText",methods.onText);
- Assert.assertThat(".getOnFrames()",methods.getOnFrames().size(),is(0));
+ // Advanced, only available from @OnWebSocketFrame annotation
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
@@ -158,8 +157,7 @@ public class EventMethodsCacheTest
assertHasEventMethod(classId + ".onConnect",methods.onConnect);
assertNoEventMethod(classId + ".onException",methods.onException);
assertHasEventMethod(classId + ".onText",methods.onText);
-
- Assert.assertThat(".getOnFrames()",methods.getOnFrames().size(),is(0));
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
@@ -171,15 +169,16 @@ public class EventMethodsCacheTest
EventMethodsCache cache = new EventMethodsCache();
EventMethods methods = cache.getMethods(MyEchoSocket.class);
- Assert.assertThat("EventMethods for MyEchoSocket",methods,notNullValue());
+ String classId = MyEchoSocket.class.getSimpleName();
- assertNoEventMethod("MyEchoSocket.onBinary",methods.onBinary);
- assertHasEventMethod("MyEchoSocket.onClose",methods.onClose);
- assertHasEventMethod("MyEchoSocket.onConnect",methods.onConnect);
- assertNoEventMethod("MyEchoSocket.onException",methods.onException);
- assertHasEventMethod("MyEchoSocket.onText",methods.onText);
+ Assert.assertThat("EventMethods for " + classId,methods,notNullValue());
- Assert.assertThat("MyEchoSocket.getOnFrames()",methods.getOnFrames().size(),is(0));
+ assertNoEventMethod(classId + ".onBinary",methods.onBinary);
+ assertHasEventMethod(classId + ".onClose",methods.onClose);
+ assertHasEventMethod(classId + ".onConnect",methods.onConnect);
+ assertNoEventMethod(classId + ".onException",methods.onException);
+ assertHasEventMethod(classId + ".onText",methods.onText);
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
@@ -191,15 +190,16 @@ public class EventMethodsCacheTest
EventMethodsCache cache = new EventMethodsCache();
EventMethods methods = cache.getMethods(MyStatelessEchoSocket.class);
- Assert.assertThat("EventMethods for MyStatelessEchoSocket",methods,notNullValue());
+ String classId = MyStatelessEchoSocket.class.getSimpleName();
- assertNoEventMethod("MyStatelessEchoSocket.onBinary",methods.onBinary);
- assertNoEventMethod("MyStatelessEchoSocket.onClose",methods.onClose);
- assertNoEventMethod("MyStatelessEchoSocket.onConnect",methods.onConnect);
- assertNoEventMethod("MyStatelessEchoSocket.onException",methods.onException);
- assertHasEventMethod("MyStatelessEchoSocket.onText",methods.onText);
+ Assert.assertThat("EventMethods for " + classId,methods,notNullValue());
- Assert.assertThat("MyEchoSocket.getOnFrames()",methods.getOnFrames().size(),is(0));
+ assertNoEventMethod(classId + ".onBinary",methods.onBinary);
+ assertNoEventMethod(classId + ".onClose",methods.onClose);
+ assertNoEventMethod(classId + ".onConnect",methods.onConnect);
+ assertNoEventMethod(classId + ".onException",methods.onException);
+ assertHasEventMethod(classId + ".onText",methods.onText);
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
@@ -211,19 +211,20 @@ public class EventMethodsCacheTest
EventMethodsCache cache = new EventMethodsCache();
EventMethods methods = cache.getMethods(NoopSocket.class);
- Assert.assertThat("Methods for NoopSocket",methods,notNullValue());
+ String classId = NoopSocket.class.getSimpleName();
- assertNoEventMethod("NoopSocket.onBinary",methods.onBinary);
- assertNoEventMethod("NoopSocket.onClose",methods.onClose);
- assertNoEventMethod("NoopSocket.onConnect",methods.onConnect);
- assertNoEventMethod("NoopSocket.onException",methods.onException);
- assertNoEventMethod("NoopSocket.onText",methods.onText);
+ Assert.assertThat("Methods for " + classId,methods,notNullValue());
- Assert.assertThat("MyEchoSocket.getOnFrames()",methods.getOnFrames().size(),is(0));
+ assertNoEventMethod(classId + ".onBinary",methods.onBinary);
+ assertNoEventMethod(classId + ".onClose",methods.onClose);
+ assertNoEventMethod(classId + ".onConnect",methods.onConnect);
+ assertNoEventMethod(classId + ".onException",methods.onException);
+ assertNoEventMethod(classId + ".onText",methods.onText);
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
- * Test Case for no exceptions and 3 methods
+ * Test Case for no exceptions and 1 methods
*/
@Test
public void testAnnotatedOnFrame()
@@ -231,17 +232,16 @@ public class EventMethodsCacheTest
EventMethodsCache cache = new EventMethodsCache();
EventMethods methods = cache.getMethods(FrameSocket.class);
- Assert.assertThat("EventMethods for MyEchoSocket",methods,notNullValue());
+ String classId = FrameSocket.class.getSimpleName();
- assertNoEventMethod("MyEchoSocket.onBinary",methods.onBinary);
- assertNoEventMethod("MyEchoSocket.onClose",methods.onClose);
- assertNoEventMethod("MyEchoSocket.onConnect",methods.onConnect);
- assertNoEventMethod("MyEchoSocket.onException",methods.onException);
- assertNoEventMethod("MyEchoSocket.onText",methods.onText);
+ Assert.assertThat("EventMethods for " + classId,methods,notNullValue());
- Assert.assertThat("MyEchoSocket.getOnFrames()",methods.getOnFrames().size(),is(2));
- assertHasEventMethod("MyEchoSocket.onFrame(BaseFrame)",methods.getOnFrame(BaseFrame.class));
- assertHasEventMethod("MyEchoSocket.onFrame(BaseFrame)",methods.getOnFrame(TextFrame.class));
+ assertNoEventMethod(classId + ".onBinary",methods.onBinary);
+ assertNoEventMethod(classId + ".onClose",methods.onClose);
+ assertNoEventMethod(classId + ".onConnect",methods.onConnect);
+ assertNoEventMethod(classId + ".onException",methods.onException);
+ assertNoEventMethod(classId + ".onText",methods.onText);
+ assertHasEventMethod(classId + ".onFrame",methods.onFrame);
}
/**
@@ -281,7 +281,6 @@ public class EventMethodsCacheTest
assertHasEventMethod(classId + ".onBinary",methods.onBinary);
assertHasEventMethod(classId + ".onException",methods.onException);
assertHasEventMethod(classId + ".onText",methods.onText);
-
- Assert.assertThat(".getOnFrames()",methods.getOnFrames().size(),is(0));
+ assertNoEventMethod(classId + ".onFrame",methods.onFrame);
}
}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/WebSocketEventDriverTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/WebSocketEventDriverTest.java
index 72dc5421dc0..1992c31bceb 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/WebSocketEventDriverTest.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/WebSocketEventDriverTest.java
@@ -2,8 +2,8 @@ package org.eclipse.jetty.websocket.api;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.api.samples.AdapterConnectCloseSocket;
-import org.eclipse.jetty.websocket.api.samples.AnnotatedByteArraySocket;
-import org.eclipse.jetty.websocket.api.samples.AnnotatedByteBufferSocket;
+import org.eclipse.jetty.websocket.api.samples.AnnotatedBinaryArraySocket;
+import org.eclipse.jetty.websocket.api.samples.AnnotatedBinaryStreamSocket;
import org.eclipse.jetty.websocket.api.samples.AnnotatedFramesSocket;
import org.eclipse.jetty.websocket.api.samples.ListenerBasicSocket;
import org.eclipse.jetty.websocket.frames.BinaryFrame;
@@ -46,7 +46,7 @@ public class WebSocketEventDriverTest
@Test
public void testAnnotated_ByteArray()
{
- AnnotatedByteArraySocket socket = new AnnotatedByteArraySocket();
+ AnnotatedBinaryArraySocket socket = new AnnotatedBinaryArraySocket();
WebSocketEventDriver driver = newDriver(socket);
LocalWebSocketConnection conn = new LocalWebSocketConnection(testname);
@@ -64,7 +64,7 @@ public class WebSocketEventDriverTest
@Test
public void testAnnotated_ByteBuffer()
{
- AnnotatedByteBufferSocket socket = new AnnotatedByteBufferSocket();
+ AnnotatedBinaryStreamSocket socket = new AnnotatedBinaryStreamSocket();
WebSocketEventDriver driver = newDriver(socket);
LocalWebSocketConnection conn = new LocalWebSocketConnection(testname);
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryArraySocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryArraySocket.java
new file mode 100644
index 00000000000..b507c7d9026
--- /dev/null
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryArraySocket.java
@@ -0,0 +1,33 @@
+package org.eclipse.jetty.websocket.api.samples;
+
+import org.eclipse.jetty.websocket.annotations.OnWebSocketClose;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketMessage;
+import org.eclipse.jetty.websocket.annotations.WebSocket;
+import org.eclipse.jetty.websocket.api.EventCapture;
+import org.eclipse.jetty.websocket.api.WebSocketConnection;
+
+@WebSocket
+public class AnnotatedBinaryArraySocket
+{
+ public EventCapture capture = new EventCapture();
+
+ @OnWebSocketMessage
+ public void onBinary(byte payload[], int offset, int length)
+ {
+ capture.add("onBinary([%d],%d,%d)",payload.length,offset,length);
+ }
+
+ @OnWebSocketClose
+ public void onClose(int statusCode, String reason)
+ {
+ capture.add("onClose(%d, %s)",statusCode,capture.q(reason));
+ }
+
+ @OnWebSocketConnect
+ public void onConnect(WebSocketConnection conn)
+ {
+ capture.add("onConnect(%s)", conn);
+ }
+
+}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryStreamSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryStreamSocket.java
new file mode 100644
index 00000000000..9deae2e0e83
--- /dev/null
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedBinaryStreamSocket.java
@@ -0,0 +1,35 @@
+package org.eclipse.jetty.websocket.api.samples;
+
+import java.io.InputStream;
+
+import org.eclipse.jetty.websocket.annotations.OnWebSocketClose;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketMessage;
+import org.eclipse.jetty.websocket.annotations.WebSocket;
+import org.eclipse.jetty.websocket.api.EventCapture;
+import org.eclipse.jetty.websocket.api.WebSocketConnection;
+
+@WebSocket
+public class AnnotatedBinaryStreamSocket
+{
+ public EventCapture capture = new EventCapture();
+
+ @OnWebSocketMessage
+ public void onBinary(InputStream stream)
+ {
+ capture.add("onBinary(%s)",stream);
+ }
+
+ @OnWebSocketClose
+ public void onClose(int statusCode, String reason)
+ {
+ capture.add("onClose(%d, %s)",statusCode,capture.q(reason));
+ }
+
+ @OnWebSocketConnect
+ public void onConnect(WebSocketConnection conn)
+ {
+ capture.add("onConnect(%s)", conn);
+ }
+
+}
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteArraySocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextSocket.java
similarity index 87%
rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteArraySocket.java
rename to jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextSocket.java
index c112dd784e4..4de0a4185af 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteArraySocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextSocket.java
@@ -1,18 +1,18 @@
package org.eclipse.jetty.websocket.api.samples;
-import org.eclipse.jetty.websocket.annotations.OnWebSocketBinary;
import org.eclipse.jetty.websocket.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.EventCapture;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
@WebSocket
-public class AnnotatedByteArraySocket
+public class AnnotatedTextSocket
{
public EventCapture capture = new EventCapture();
- @OnWebSocketBinary
+ @OnWebSocketMessage
public void onBinary(byte payload[], int offset, int length)
{
capture.add("onBinary([%d],%d,%d)",payload.length,offset,length);
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteBufferSocket.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextStreamSocket.java
similarity index 74%
rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteBufferSocket.java
rename to jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextStreamSocket.java
index 1a4f0c80b74..a62a5a25182 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedByteBufferSocket.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/api/samples/AnnotatedTextStreamSocket.java
@@ -1,25 +1,19 @@
package org.eclipse.jetty.websocket.api.samples;
-import java.nio.ByteBuffer;
+import java.io.Reader;
-import org.eclipse.jetty.websocket.annotations.OnWebSocketBinary;
import org.eclipse.jetty.websocket.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.EventCapture;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
@WebSocket
-public class AnnotatedByteBufferSocket
+public class AnnotatedTextStreamSocket
{
public EventCapture capture = new EventCapture();
- @OnWebSocketBinary
- public void onBinary(ByteBuffer payload)
- {
- capture.add("onBinary(%s)",payload);
- }
-
@OnWebSocketClose
public void onClose(int statusCode, String reason)
{
@@ -32,4 +26,9 @@ public class AnnotatedByteBufferSocket
capture.add("onConnect(%s)", conn);
}
+ @OnWebSocketMessage
+ public void onText(Reader reader)
+ {
+ capture.add("onText(%s)",reader);
+ }
}