View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.websocket.server;
20  
21  import java.net.InetSocketAddress;
22  import java.util.concurrent.Executor;
23  
24  import org.eclipse.jetty.io.ByteBufferPool;
25  import org.eclipse.jetty.io.Connection;
26  import org.eclipse.jetty.io.EndPoint;
27  import org.eclipse.jetty.util.thread.Scheduler;
28  import org.eclipse.jetty.websocket.api.WebSocketPolicy;
29  import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
30  import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
31  
32  public class WebSocketServerConnection extends AbstractWebSocketConnection implements Connection.UpgradeTo
33  {
34      public WebSocketServerConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
35      {
36          super(endp,executor,scheduler,policy,bufferPool);
37          if (policy.getIdleTimeout() > 0)
38          {
39              endp.setIdleTimeout(policy.getIdleTimeout());
40          }
41      }
42      
43      @Override
44      public InetSocketAddress getLocalAddress()
45      {
46          return getEndPoint().getLocalAddress();
47      }
48  
49      @Override
50      public InetSocketAddress getRemoteAddress()
51      {
52          return getEndPoint().getRemoteAddress();
53      }
54      
55      @Override
56      public void setNextIncomingFrames(IncomingFrames incoming)
57      {
58          getParser().setIncomingFramesHandler(incoming);
59      }
60  }