Websocket support was present prior to Pedestal 0.7, but was a container-specific option for Jetty. In Pedestal 0.7, websocket support was refactored to be more universal and declarative, part of the service-map.adoc. |
Websockets are an asynchronous and bidirectional connection between a client and a server. Once a Websocket connection is established, either party may send messages to the other party - this unleashes truly unbounded possibilities for creating dynamic, real-time, and asynchronous applications.
Websocket requests are not routed the way HTTP requests are; instead, the mapping from incoming requests to Websocket handlers is defined in the service-map.adoc.
The endpoint map is a set of callbacks. The path and endpoint map are ultimately passed to the api:add-endpoint[] function, which describes in detail how the callbacks are used.
Essentially, the :on-open callback is invoked when the client initiates the connection.
It is intended that, when the client connects, some form of server-side process will be initiated capable of sending messages to the client asynchronously. It is the responsibility of the :on-open callback to create such a process. One common option is to use the api:on-open-start-ws-connection[] function to create the callback, or construct the :on-open callback around the api:start-ws-connection[] function.
The :on-string and :on-binary callbacks are invoked when a text or binary message from the client is received.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close