402148 - Update Javadoc for WebSocketServlet for new API

This commit is contained in:
Joakim Erdfelt 2013-03-01 09:31:29 -07:00
parent 9e78529a17
commit 79630de1f1
3 changed files with 75 additions and 4 deletions

View File

@ -42,15 +42,17 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket;
* <pre>
* package my.example;
*
* import javax.servlet.http.HttpServletRequest;
* import org.eclipse.jetty.websocket.WebSocket;
* import org.eclipse.jetty.websocket.server.WebSocketServlet;
* import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
* import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
*
* public class MyEchoServlet extends WebSocketServlet
* {
* &#064;Override
* public void registerWebSockets(WebSocketServerFactory factory)
* public void configure(WebSocketServletFactory factory)
* {
* // set a 10 second idle timeout
* factory.getPolicy().setIdleTimeout(10000);
* // register my socket
* factory.register(MyEchoSocket.class);
* }
* }

View File

@ -0,0 +1,35 @@
//
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package examples;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
@SuppressWarnings("serial")
public class MyExampleServlet extends WebSocketServlet
{
@Override
public void configure(WebSocketServletFactory factory)
{
// set a 10 second timeout
factory.getPolicy().setIdleTimeout(10000);
// register my socket
factory.register(MyExampleSocket.class);
}
}

View File

@ -0,0 +1,34 @@
//
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package examples;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
/**
* Example WebSocket, simple echo
*/
public class MyExampleSocket extends WebSocketAdapter
{
@Override
public void onWebSocketText(String message)
{
// Echo message back, asynchronously
getSession().getRemote().sendStringByFuture(message);
}
}