org.eclipse.jetty.websocket

## Class WebSocketFactory

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.websocket.WebSocketFactory

All Implemented Interfaces:
  LifeCycle

    public class WebSocketFactory
    extends AbstractLifeCycle

Factory to create WebSocket connections

### Nested Class Summary

Nested Classes
`static interface` `WebSocketFactory.Acceptor`

### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`AbstractLifeCycle.AbstractLifeCycleListener`

### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

`LifeCycle.Listener`

### Field Summary

### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

### Constructor Summary

Constructors
Constructor and Description
`WebSocketFactory(WebSocketFactory.Acceptor acceptor)`
`WebSocketFactory(WebSocketFactory.Acceptor acceptor, int bufferSize)`
`WebSocketFactory(WebSocketFactory.Acceptor acceptor, int bufferSize, int minVersion)`

### Method Summary

Methods
`boolean` `acceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
`protected boolean` `addConnection(WebSocketServletConnection connection)`
`protected void` `closeConnections()`
`protected void` `doStop()`
`int` `getBufferSize()` Get the bufferSize.
`Map<String,Class<? extends Extension>>` `getExtensionClassesMap()`
`int` `getMaxBinaryMessageSize()`
`long` `getMaxIdleTime()` Get the maxIdleTime.
`int` `getMaxTextMessageSize()`
`int` `getMinVersion()`
`List<Extension>` `initExtensions(List<String> requested, int maxDataOpcodes, int maxControlOpcodes, int maxReservedBits)`
`protected String[]` `parseProtocols(String protocol)`
`protected boolean` `removeConnection(WebSocketServletConnection connection)`
`void` `setBufferSize(int bufferSize)` Set the bufferSize.
`void` `setMaxBinaryMessageSize(int maxBinaryMessageSize)` Set the initial maximum binary message size for a connection.
`void` `setMaxIdleTime(int maxIdleTime)` Set the maxIdleTime.
`void` `setMaxTextMessageSize(int maxTextMessageSize)` Set the initial maximum text message size for a connection.
`void` `setMinVersion(int minVersion)`
`void` `upgrade(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebSocket websocket, String protocol)` Upgrade the request/response to a WebSocket Connection.

### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`addLifeCycleListener, doStart, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### WebSocketFactory

    public WebSocketFactory(WebSocketFactory.Acceptor acceptor)

#### WebSocketFactory

    public WebSocketFactory(WebSocketFactory.Acceptor acceptor,
                    int bufferSize)

#### WebSocketFactory

    public WebSocketFactory(WebSocketFactory.Acceptor acceptor,
                    int bufferSize,
                    int minVersion)

### Method Detail

#### getMinVersion

    public int getMinVersion()

#### setMinVersion

    public void setMinVersion(int minVersion)

Parameters:
  `minVersion` - The minimum support version (default RCF6455.VERSION == 13 )

#### getExtensionClassesMap

    public Map<String,Class<? extends Extension>> getExtensionClassesMap()

Returns:
  A modifiable map of extension name to extension class

#### getMaxIdleTime

    public long getMaxIdleTime()

Get the maxIdleTime.

Returns:
  the maxIdleTime

#### setMaxIdleTime

    public void setMaxIdleTime(int maxIdleTime)

Set the maxIdleTime.

Parameters:
  `maxIdleTime` - the maxIdleTime to set

#### getBufferSize

    public int getBufferSize()

Get the bufferSize.

Returns:
  the bufferSize

#### setBufferSize

    public void setBufferSize(int bufferSize)

Set the bufferSize.

Parameters:
  `bufferSize` - the bufferSize to set

#### getMaxTextMessageSize

    public int getMaxTextMessageSize()

Returns:
  The initial maximum text message size (in characters) for a connection

#### setMaxTextMessageSize

    public void setMaxTextMessageSize(int maxTextMessageSize)

Set the initial maximum text message size for a connection. This can be changed by the application calling `WebSocket.Connection.setMaxTextMessageSize(int)`.

Parameters:
  `maxTextMessageSize` - The default maximum text message size (in characters) for a connection

#### getMaxBinaryMessageSize

    public int getMaxBinaryMessageSize()

Returns:
  The initial maximum binary message size (in bytes) for a connection

#### setMaxBinaryMessageSize

    public void setMaxBinaryMessageSize(int maxBinaryMessageSize)

Set the initial maximum binary message size for a connection. This can be changed by the application calling `WebSocket.Connection.setMaxBinaryMessageSize(int)`.

Parameters:
  `maxBinaryMessageSize` - The default maximum binary message size (in bytes) for a connection

#### doStop

    protected void doStop()
                   throws Exception

Overrides:
  `doStop` in class `AbstractLifeCycle`
Throws:
  `Exception`

#### upgrade

    public void upgrade(javax.servlet.http.HttpServletRequest request,
               javax.servlet.http.HttpServletResponse response,
               WebSocket websocket,
               String protocol)
                 throws IOException

Upgrade the request/response to a WebSocket Connection.

This method will not normally return, but will instead throw a UpgradeConnectionException, to exit HTTP handling and initiate WebSocket handling of the connection.

Parameters:
  `request` - The request to upgrade
  `response` - The response to upgrade
  `websocket` - The websocket handler implementation to use
  `protocol` - The websocket protocol
Throws:
  `IOException` - in case of I/O errors

#### parseProtocols

    protected String[] parseProtocols(String protocol)

#### acceptWebSocket

    public boolean acceptWebSocket(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                            throws IOException

Throws:
  `IOException`

#### initExtensions

    public List<Extension> initExtensions(List<String> requested,
                                 int maxDataOpcodes,
                                 int maxControlOpcodes,
                                 int maxReservedBits)

#### addConnection

    protected boolean addConnection(WebSocketServletConnection connection)

#### removeConnection

    protected boolean removeConnection(WebSocketServletConnection connection)

#### closeConnections

    protected void closeConnections()