Package io.undertow.websockets.spi
Class AsyncWebSocketHttpServerExchange
- java.lang.Object
-
- io.undertow.websockets.spi.AsyncWebSocketHttpServerExchange
-
- All Implemented Interfaces:
WebSocketHttpExchange
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
BlockingWebSocketHttpServerExchange
public class AsyncWebSocketHttpServerExchange extends java.lang.Object implements WebSocketHttpExchange
- Author:
- Stuart Douglas
-
-
Constructor Summary
Constructors Constructor Description AsyncWebSocketHttpServerExchange(HttpServerExchange exchange, java.util.Set<WebSocketChannel> peerConnections)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Forcibly close the exchange.void
endExchange()
End the exchange normally.<T> T
getAttachment(AttachmentKey<T> key)
ByteBufferPool
getBufferPool()
org.xnio.OptionMap
getOptions()
java.util.Set<WebSocketChannel>
getPeerConnections()
java.lang.String
getQueryString()
java.lang.String
getRequestHeader(java.lang.String headerName)
gets the first request header with the specified namejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
getRequestHeaders()
java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getRequestParameters()
java.lang.String
getRequestScheme()
Get the request scheme, usually http or httpsjava.lang.String
getRequestURI()
java.lang.String
getResponseHeader(java.lang.String headerName)
get a response headerjava.util.Map<java.lang.String,java.util.List<java.lang.String>>
getResponseHeaders()
java.lang.Object
getSession()
Gets the session, if anyjava.security.Principal
getUserPrincipal()
boolean
isUserInRole(java.lang.String role)
<T> void
putAttachment(AttachmentKey<T> key, T value)
org.xnio.IoFuture<byte[]>
readRequestData()
Gets the body of the request.org.xnio.IoFuture<java.lang.Void>
sendData(java.nio.ByteBuffer data)
Send some datavoid
setResponseHeader(java.lang.String headerName, java.lang.String headerValue)
Set a response headervoid
setResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
Sets the response headersvoid
upgradeChannel(HttpUpgradeListener upgradeCallback)
Upgrade the underlying channel
-
-
-
Constructor Detail
-
AsyncWebSocketHttpServerExchange
public AsyncWebSocketHttpServerExchange(HttpServerExchange exchange, java.util.Set<WebSocketChannel> peerConnections)
-
-
Method Detail
-
putAttachment
public <T> void putAttachment(AttachmentKey<T> key, T value)
- Specified by:
putAttachment
in interfaceWebSocketHttpExchange
-
getAttachment
public <T> T getAttachment(AttachmentKey<T> key)
- Specified by:
getAttachment
in interfaceWebSocketHttpExchange
-
getRequestHeader
public java.lang.String getRequestHeader(java.lang.String headerName)
Description copied from interface:WebSocketHttpExchange
gets the first request header with the specified name- Specified by:
getRequestHeader
in interfaceWebSocketHttpExchange
- Parameters:
headerName
- The header name- Returns:
- The header value, or null
-
getRequestHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestHeaders()
- Specified by:
getRequestHeaders
in interfaceWebSocketHttpExchange
- Returns:
- An unmodifiable map of request headers
-
getResponseHeader
public java.lang.String getResponseHeader(java.lang.String headerName)
Description copied from interface:WebSocketHttpExchange
get a response header- Specified by:
getResponseHeader
in interfaceWebSocketHttpExchange
- Parameters:
headerName
- The header name- Returns:
- The header value, or null
-
getResponseHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
- Specified by:
getResponseHeaders
in interfaceWebSocketHttpExchange
- Returns:
- An unmodifiable map of response headers
-
setResponseHeaders
public void setResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
Description copied from interface:WebSocketHttpExchange
Sets the response headers- Specified by:
setResponseHeaders
in interfaceWebSocketHttpExchange
-
setResponseHeader
public void setResponseHeader(java.lang.String headerName, java.lang.String headerValue)
Description copied from interface:WebSocketHttpExchange
Set a response header- Specified by:
setResponseHeader
in interfaceWebSocketHttpExchange
- Parameters:
headerName
- The header nameheaderValue
- The header value
-
upgradeChannel
public void upgradeChannel(HttpUpgradeListener upgradeCallback)
Description copied from interface:WebSocketHttpExchange
Upgrade the underlying channel- Specified by:
upgradeChannel
in interfaceWebSocketHttpExchange
-
sendData
public org.xnio.IoFuture<java.lang.Void> sendData(java.nio.ByteBuffer data)
Description copied from interface:WebSocketHttpExchange
Send some data- Specified by:
sendData
in interfaceWebSocketHttpExchange
- 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 interfaceWebSocketHttpExchange
-
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 interfaceWebSocketHttpExchange
-
close
public void close()
Description copied from interface:WebSocketHttpExchange
Forcibly close the exchange.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceWebSocketHttpExchange
-
getRequestScheme
public java.lang.String getRequestScheme()
Description copied from interface:WebSocketHttpExchange
Get the request scheme, usually http or https- Specified by:
getRequestScheme
in interfaceWebSocketHttpExchange
- Returns:
- The request scheme
-
getRequestURI
public java.lang.String getRequestURI()
- Specified by:
getRequestURI
in interfaceWebSocketHttpExchange
- Returns:
- The request URI, including the query string
-
getBufferPool
public ByteBufferPool getBufferPool()
- Specified by:
getBufferPool
in interfaceWebSocketHttpExchange
- Returns:
- The buffer pool
-
getQueryString
public java.lang.String getQueryString()
- Specified by:
getQueryString
in interfaceWebSocketHttpExchange
- Returns:
- The query string
-
getSession
public java.lang.Object getSession()
Description copied from interface:WebSocketHttpExchange
Gets the session, if any- Specified by:
getSession
in interfaceWebSocketHttpExchange
- Returns:
- The session object, or null
-
getRequestParameters
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestParameters()
- Specified by:
getRequestParameters
in interfaceWebSocketHttpExchange
-
getUserPrincipal
public java.security.Principal getUserPrincipal()
- Specified by:
getUserPrincipal
in interfaceWebSocketHttpExchange
-
isUserInRole
public boolean isUserInRole(java.lang.String role)
- Specified by:
isUserInRole
in interfaceWebSocketHttpExchange
-
getPeerConnections
public java.util.Set<WebSocketChannel> getPeerConnections()
- Specified by:
getPeerConnections
in interfaceWebSocketHttpExchange
-
getOptions
public org.xnio.OptionMap getOptions()
- Specified by:
getOptions
in interfaceWebSocketHttpExchange
-
-