Author: remm Date: Fri May 30 07:52:52 2014 New Revision: 1598483 URL: http://svn.apache.org/r1598483 Log: - Test autobahn myself, add two new echo endpoints and my example config. - Issues with the async endpoint, 9.7 and 9.8.
Added: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAsyncAnnotation.java tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStreamAnnotation.java tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/servers.json Modified: tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1598483&r1=1598482&r2=1598483&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri May 30 07:52:52 2014 @@ -135,6 +135,9 @@ status code of the response, ensure that only one connection header is sent to the client. (markt) </fix> + <fix> + Fix input concurrency issue in NIO2 upgrade. (remm) + </fix> </changelog> </subsection> <subsection name="Jasper"> @@ -176,6 +179,9 @@ the resulting <code>IllegalStateException</code> in a manner consistent with the handling of an <code>IOException</code>. (markt) </fix> + <fix> + Add more varied endpoints for echo testing. (remm) + </fix> </changelog> </subsection> <subsection name="Other"> Added: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAsyncAnnotation.java URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAsyncAnnotation.java?rev=1598483&view=auto ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAsyncAnnotation.java (added) +++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAsyncAnnotation.java Fri May 30 07:52:52 2014 @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package websocket.echo; + +import java.io.IOException; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.ByteBuffer; + +import javax.websocket.OnMessage; +import javax.websocket.PongMessage; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +@ServerEndpoint("/websocket/echoAsyncAnnotation") +public class EchoAsyncAnnotation { + + StringBuilder sb = null; + ByteArrayOutputStream bytes = null; + + @OnMessage + public void echoTextMessage(Session session, String msg, boolean last) + throws IOException { + if (sb == null) { + sb = new StringBuilder(); + } + sb.append(msg); + if (last) { + //System.out.println("Write: " + sb.length()); + session.getAsyncRemote().sendText(sb.toString()); + sb = null; + } + } + + @OnMessage + public void echoBinaryMessage(byte[] msg, Session session, boolean last) + throws IOException { + if (bytes == null) { + bytes = new ByteArrayOutputStream(); + } + bytes.write(msg); + //System.out.println("Got: " + msg.length + " " + last + " " + bytes.size()); + if (last) { + //System.out.println("Write bytes: " + bytes.size()); + session.getAsyncRemote().sendBinary(ByteBuffer.wrap(bytes.toByteArray())); + bytes = null; + } + } + + /** + * Process a received pong. This is a NO-OP. + * + * @param pm Ignored. + */ + @OnMessage + public void echoPongMessage(PongMessage pm) { + // NO-OP + } +} Added: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStreamAnnotation.java URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStreamAnnotation.java?rev=1598483&view=auto ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStreamAnnotation.java (added) +++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStreamAnnotation.java Fri May 30 07:52:52 2014 @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package websocket.echo; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.ByteBuffer; + +import javax.websocket.OnMessage; +import javax.websocket.PongMessage; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +@ServerEndpoint("/websocket/echoStreamAnnotation") +public class EchoStreamAnnotation { + + Writer writer; + OutputStream stream; + + @OnMessage + public void echoTextMessage(Session session, String msg, boolean last) + throws IOException { + if (writer == null) { + writer = session.getBasicRemote().getSendWriter(); + } + writer.write(msg); + if (last) { + writer.close(); + writer = null; + } + } + + @OnMessage + public void echoBinaryMessage(byte[] msg, Session session, boolean last) + throws IOException { + if (stream == null) { + stream = session.getBasicRemote().getSendStream(); + } + stream.write(msg); + stream.flush(); + if (last) { + stream.close(); + stream = null; + } + } + + /** + * Process a received pong. This is a NO-OP. + * + * @param pm Ignored. + */ + @OnMessage + public void echoPongMessage(PongMessage pm) { + // NO-OP + } +} Added: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/servers.json URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/servers.json?rev=1598483&view=auto ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/servers.json (added) +++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/servers.json Fri May 30 07:52:52 2014 @@ -0,0 +1,20 @@ +{ + "options": {"failByDrop": false}, + "outdir": "./reports/servers", + + "servers": [ + {"agent": "Basic", + "url": "ws://localhost:8080/examples/websocket/echoAnnotation", + "options": {"version": 18}}, + {"agent": "Stream", + "url": "ws://localhost:8080/examples/websocket/echoStreamAnnotation", + "options": {"version": 18}}, + {"agent": "Async", + "url": "ws://localhost:8080/examples/websocket/echoAsyncAnnotation", + "options": {"version": 18}} + ], + + "cases": ["*"], + "exclude-cases": [], + "exclude-agent-cases": {} +} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org