2015-05-11 23:05:18 +02:00
|
|
|
.. _-handleWebsocketMessages-:
|
|
|
|
|
|
|
|
|
|
handleWebsocketMessages
|
|
|
|
|
=======================
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2015-06-19 15:35:24 +02:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/WebsocketDirectives.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: handleWebsocketMessages
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
|
|
|
|
|
2015-08-24 12:03:37 +02: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``.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
For more information about the Websocket support, see :ref:`server-side-websocket-support-scala`.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2015-08-24 12:03:37 +02:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/WebsocketDirectivesExamplesSpec.scala
|
|
|
|
|
:snippet: greeter-service
|