io.undertow.websockets.spi

## Class AsyncWebSocketHttpServerExchange

- java.lang.Object
- - io.undertow.websockets.spi.AsyncWebSocketHttpServerExchange

All Implemented Interfaces:
  WebSocketHttpExchange, Closeable, AutoCloseable

Direct Known Subclasses:
  BlockingWebSocketHttpServerExchange

    public class AsyncWebSocketHttpServerExchange
    extends Object
    implements WebSocketHttpExchange

Author:
  Stuart Douglas

### Constructor Summary

Constructors
Constructor and Description
`AsyncWebSocketHttpServerExchange(HttpServerExchange exchange, Set<WebSocketChannel> peerConnections)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Forcibly close the exchange.
`void` `endExchange()` End the exchange normally.
`<T> T` `getAttachment(AttachmentKey<T> key)`
`ByteBufferPool` `getBufferPool()`
`org.xnio.OptionMap` `getOptions()`
`Set<WebSocketChannel>` `getPeerConnections()`
`String` `getQueryString()`
`String` `getRequestHeader(String headerName)` gets the first request header with the specified name
`Map<String,List<String>>` `getRequestHeaders()`
`Map<String,List<String>>` `getRequestParameters()`
`String` `getRequestScheme()` Get the request scheme, usually http or https
`String` `getRequestURI()`
`String` `getResponseHeader(String headerName)` get a response header
`Map<String,List<String>>` `getResponseHeaders()`
`Object` `getSession()` Gets the session, if any
`Principal` `getUserPrincipal()`
`boolean` `isUserInRole(String role)`
`<T> void` `putAttachment(AttachmentKey<T> key, T value)`
`org.xnio.IoFuture<byte[]>` `readRequestData()` Gets the body of the request.
`org.xnio.IoFuture<Void>` `sendData(ByteBuffer data)` Send some data
`void` `setResponseHeader(String headerName, String headerValue)` Set a response header
`void` `setResponseHeaders(Map<String,List<String>> headers)` Sets the response headers
`void` `upgradeChannel(HttpUpgradeListener upgradeCallback)` Upgrade the underlying channel

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

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

### Constructor Detail

#### AsyncWebSocketHttpServerExchange

    public AsyncWebSocketHttpServerExchange(HttpServerExchange exchange,
                                            Set<WebSocketChannel> peerConnections)

### Method Detail

#### putAttachment

    public <T> void putAttachment(AttachmentKey<T> key,
                                  T value)

Specified by:
  `putAttachment` in interface `WebSocketHttpExchange`

#### getAttachment

    public <T> T getAttachment(AttachmentKey<T> key)

Specified by:
  `getAttachment` in interface `WebSocketHttpExchange`

#### getRequestHeader

    public String getRequestHeader(String headerName)

Description copied from interface: `WebSocketHttpExchange`
gets the first request header with the specified name

Specified by:
  `getRequestHeader` in interface `WebSocketHttpExchange`
Parameters:
  `headerName` - The header name
Returns:
  The header value, or null

#### getRequestHeaders

    public Map<String,List<String>> getRequestHeaders()

Specified by:
  `getRequestHeaders` in interface `WebSocketHttpExchange`
Returns:
  An unmodifiable map of request headers

#### getResponseHeader

    public String getResponseHeader(String headerName)

Description copied from interface: `WebSocketHttpExchange`
get a response header

Specified by:
  `getResponseHeader` in interface `WebSocketHttpExchange`
Parameters:
  `headerName` - The header name
Returns:
  The header value, or null

#### getResponseHeaders

    public Map<String,List<String>> getResponseHeaders()

Specified by:
  `getResponseHeaders` in interface `WebSocketHttpExchange`
Returns:
  An unmodifiable map of response headers

#### setResponseHeaders

    public void setResponseHeaders(Map<String,List<String>> headers)

Description copied from interface: `WebSocketHttpExchange`
Sets the response headers

Specified by:
  `setResponseHeaders` in interface `WebSocketHttpExchange`

#### setResponseHeader

    public void setResponseHeader(String headerName,
                                  String headerValue)

Description copied from interface: `WebSocketHttpExchange`
Set a response header

Specified by:
  `setResponseHeader` in interface `WebSocketHttpExchange`
Parameters:
  `headerName` - The header name
  `headerValue` - The header value

#### upgradeChannel

    public void upgradeChannel(HttpUpgradeListener upgradeCallback)

Description copied from interface: `WebSocketHttpExchange`
Upgrade the underlying channel

Specified by:
  `upgradeChannel` in interface `WebSocketHttpExchange`

#### sendData

    public org.xnio.IoFuture<Void> sendData(ByteBuffer data)

Description copied from interface: `WebSocketHttpExchange`
Send some data

Specified by:
  `sendData` in interface `WebSocketHttpExchange`
Parameters:
  `data` - The data

#### readRequestData

    public org.xnio.IoFuture<byte[]> readRequestData()

Description copied from interface: `WebSocketHttpExchange`
Gets the body of the request.

Specified by:
  `readRequestData` in interface `WebSocketHttpExchange`

#### endExchange

    public void endExchange()

Description copied from interface: `WebSocketHttpExchange`
End the exchange normally. If this is a blocking exchange this may be a noop, and the exchange will actually end when the call stack returns

Specified by:
  `endExchange` in interface `WebSocketHttpExchange`

#### close

    public void close()

Description copied from interface: `WebSocketHttpExchange`
Forcibly close the exchange.

Specified by:
  `close` in interface `WebSocketHttpExchange`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`

#### getRequestScheme

    public String getRequestScheme()

Description copied from interface: `WebSocketHttpExchange`
Get the request scheme, usually http or https

Specified by:
  `getRequestScheme` in interface `WebSocketHttpExchange`
Returns:
  The request scheme

#### getRequestURI

    public String getRequestURI()

Specified by:
  `getRequestURI` in interface `WebSocketHttpExchange`
Returns:
  The request URI, including the query string

#### getBufferPool

    public ByteBufferPool getBufferPool()

Specified by:
  `getBufferPool` in interface `WebSocketHttpExchange`
Returns:
  The buffer pool

#### getQueryString

    public String getQueryString()

Specified by:
  `getQueryString` in interface `WebSocketHttpExchange`
Returns:
  The query string

#### getSession

    public Object getSession()

Description copied from interface: `WebSocketHttpExchange`
Gets the session, if any

Specified by:
  `getSession` in interface `WebSocketHttpExchange`
Returns:
  The session object, or null

#### getRequestParameters

    public Map<String,List<String>> getRequestParameters()

Specified by:
  `getRequestParameters` in interface `WebSocketHttpExchange`

#### getUserPrincipal

    public Principal getUserPrincipal()

Specified by:
  `getUserPrincipal` in interface `WebSocketHttpExchange`

#### isUserInRole

    public boolean isUserInRole(String role)

Specified by:
  `isUserInRole` in interface `WebSocketHttpExchange`

#### getPeerConnections

    public Set<WebSocketChannel> getPeerConnections()

Specified by:
  `getPeerConnections` in interface `WebSocketHttpExchange`

#### getOptions

    public org.xnio.OptionMap getOptions()

Specified by:
  `getOptions` in interface `WebSocketHttpExchange`