2016-01-19 20:43:59 +01:00
|
|
|
.. _-handleWebSocketMessages-:
|
2015-05-11 23:05:18 +02:00
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
handleWebSocketMessages
|
2015-05-11 23:05:18 +02:00
|
|
|
=======================
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/WebSocketDirectives.scala
|
|
|
|
|
:snippet: handleWebSocketMessages
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
|
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
The directive first checks if the request was a valid WebSocket handshake request and if yes, it completes the request
|
|
|
|
|
with the passed handler. Otherwise, the request is rejected with an ``ExpectedWebSocketRequestRejection``.
|
2015-08-24 12:03:37 +02:00
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
WebSocket subprotocols offered in the ``Sec-WebSocket-Protocol`` header of the request are ignored. If you want to
|
|
|
|
|
support several protocols use the :ref:`-handleWebSocketMessagesForProtocol-` directive, instead.
|
2015-08-24 12:03:37 +02:00
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
For more information about the WebSocket support, see :ref:`server-side-websocket-support-scala`.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2016-01-19 20:43:59 +01:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/WebSocketDirectivesExamplesSpec.scala
|
2015-08-24 12:03:37 +02:00
|
|
|
:snippet: greeter-service
|