Class WebSocketService
java.lang.Object
com.linecorp.armeria.server.AbstractHttpService
com.linecorp.armeria.server.websocket.WebSocketService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,
HttpResponse>
An
HttpService
that supports
The WebSocket Protocol.-
Method Summary
Modifier and TypeMethodDescriptionstatic WebSocketServiceBuilder
builder
(WebSocketServiceHandler handler) Returns a newWebSocketServiceBuilder
with theWebSocketServiceHandler
.protected HttpResponse
doConnect
(ServiceRequestContext ctx, HttpRequest req) Handles the HTTP/2 web socket handshake described in Bootstrapping WebSockets with HTTP/2.protected HttpResponse
doGet
(ServiceRequestContext ctx, HttpRequest req) Handles the HTTP/1.1 web socket handshake described in The WebSocket Protocol.static WebSocketService
of
(WebSocketServiceHandler handler) Returns a newWebSocketService
with theWebSocketServiceHandler
.Methods inherited from class com.linecorp.armeria.server.AbstractHttpService
doDelete, doHead, doOptions, doPatch, doPost, doPut, doTrace, serve
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.HttpService
decorate, decorate, exchangeType
Methods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrap
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
of
Returns a newWebSocketService
with theWebSocketServiceHandler
. -
builder
Returns a newWebSocketServiceBuilder
with theWebSocketServiceHandler
. -
doGet
Handles the HTTP/1.1 web socket handshake described in The WebSocket Protocol. These are examples of a request and its corresponding response:Request:
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13
Response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
- Overrides:
doGet
in classAbstractHttpService
- Throws:
Exception
-
doConnect
Handles the HTTP/2 web socket handshake described in Bootstrapping WebSockets with HTTP/2. These are examples of a request and the corresponding response:Request:
HEADERS + END_HEADERS :method = CONNECT :protocol = websocket :scheme = https :path = /chat :authority = server.example.com sec-websocket-protocol = chat, superchat sec-websocket-extensions = permessage-deflate sec-websocket-version = 13 origin = http://www.example.com
Response:
HEADERS + END_HEADERS :status = 200 sec-websocket-protocol = chat
- Overrides:
doConnect
in classAbstractHttpService
- Throws:
Exception
-