com.lambkit.web.websocket.jetty.JettyWebSocketServlet Maven / Gradle / Ivy
/**
* Copyright (c) 2015-2017, Henry Yang 杨勇 ([email protected]).
*
* Licensed 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 com.lambkit.web.websocket.jetty;
import javax.servlet.annotation.WebServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
@WebServlet(name = "Lambkit_WebSocket_Servlet", urlPatterns = { "/websocket" })
public class JettyWebSocketServlet extends WebSocketServlet {
private static final long serialVersionUID = 1L;
@Override
public void configure(WebSocketServletFactory factory) {
// set a 10 second timeout
factory.getPolicy().setIdleTimeout(10000);
// register MyEchoSocket as the WebSocket to create on Upgrade
factory.register(ListenerSocket.class);
}
}