|
1 | 1 | <!DOCTYPE html> |
2 | | -<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Tiny_httpd_ws (tiny_httpd.Tiny_httpd_ws)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">Index</a> » <a href="../index.html">tiny_httpd</a> » Tiny_httpd_ws</nav><header class="odoc-preamble"><h1>Module <code><span>Tiny_httpd_ws</span></code></h1><p>Websockets for Tiny_httpd.</p><p>This sub-library (<code>tiny_httpd.ws</code>) exports a small implementation for a websocket server. It has no additional dependencies.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-handler"><a href="#type-handler" class="anchor"></a><code><span><span class="keyword">type</span> handler</span><span> = |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Tiny_httpd_ws (tiny_httpd.Tiny_httpd_ws)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">Index</a> » <a href="../index.html">tiny_httpd</a> » Tiny_httpd_ws</nav><header class="odoc-preamble"><h1>Module <code><span>Tiny_httpd_ws</span></code></h1><p>Websockets for Tiny_httpd.</p><p>This sub-library (<code>tiny_httpd.ws</code>) exports a small implementation for a websocket server. It has no additional dependencies.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module anchored" id="module-With_lock"><a href="#module-With_lock" class="anchor"></a><code><span><span class="keyword">module</span> <a href="With_lock/index.html">With_lock</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Synchronization primitive used to allow both the reader to reply to "ping", and the handler to send messages, without stepping on each other's toes.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-handler"><a href="#type-handler" class="anchor"></a><code><span><span class="keyword">type</span> handler</span><span> = |
3 | 3 | <span><span>unit <a href="../Tiny_httpd_core/Request/index.html#type-t">Tiny_httpd_core.Request.t</a></span> <span class="arrow">-></span></span> |
4 | 4 | <span><a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> <span class="arrow">-></span></span> |
5 | 5 | <span><a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a> <span class="arrow">-></span></span> |
6 | 6 | unit</span></code></div><div class="spec-doc"><p>Websocket handler</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-upgrade"><a href="#val-upgrade" class="anchor"></a><code><span><span class="keyword">val</span> upgrade : |
| 7 | + <span><span class="optlabel">?with_lock</span>:<a href="With_lock/index.html#type-t">With_lock.t</a> <span class="arrow">-></span></span> |
7 | 8 | <span><a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> <span class="arrow">-></span></span> |
8 | 9 | <span><a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a> <span class="arrow">-></span></span> |
9 | | - <a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> * <a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a></span></code></div><div class="spec-doc"><p>Upgrade a byte stream to the websocket framing protocol.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Close_connection"><a href="#exception-Close_connection" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Close_connection</span></span></code></div><div class="spec-doc"><p>Exception that can be raised from IOs inside the handler, when the connection is closed from underneath.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_route_handler"><a href="#val-add_route_handler" class="anchor"></a><code><span><span class="keyword">val</span> add_route_handler : |
| 10 | + <a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> * <a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a></span></code></div><div class="spec-doc"><p>Upgrade a byte stream to the websocket framing protocol.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">with_lock</span> <p>if provided, use this to prevent reader and writer to compete on sending frames. since NEXT_RELEASE.</p></li></ul></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Close_connection"><a href="#exception-Close_connection" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Close_connection</span></span></code></div><div class="spec-doc"><p>Exception that can be raised from IOs inside the handler, when the connection is closed from underneath.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_route_handler"><a href="#val-add_route_handler" class="anchor"></a><code><span><span class="keyword">val</span> add_route_handler : |
10 | 11 | <span><span class="optlabel">?accept</span>:<span>(<span><span>unit <a href="../Tiny_httpd_core/Request/index.html#type-t">Tiny_httpd_core.Request.t</a></span> <span class="arrow">-></span></span> <span><span>(unit, int * string)</span> <a href="../../ocaml/Stdlib/index.html#type-result">result</a></span>)</span> <span class="arrow">-></span></span> |
11 | 12 | <span><span class="optlabel">?accept_ws_protocol</span>:<span>(<span>string <span class="arrow">-></span></span> bool)</span> <span class="arrow">-></span></span> |
12 | 13 | <span><span class="optlabel">?middlewares</span>:<span><a href="../Tiny_httpd_core/Server/Head_middleware/index.html#type-t">Tiny_httpd_core.Server.Head_middleware.t</a> list</span> <span class="arrow">-></span></span> |
| 14 | + <span><span class="optlabel">?with_lock</span>:<a href="With_lock/index.html#type-builder">With_lock.builder</a> <span class="arrow">-></span></span> |
13 | 15 | <span><a href="../Tiny_httpd_core/Server/index.html#type-t">Tiny_httpd_core.Server.t</a> <span class="arrow">-></span></span> |
14 | 16 | <span><span><span>(<a href="../Tiny_httpd_core/Server/index.html#type-upgrade_handler">Tiny_httpd_core.Server.upgrade_handler</a>, |
15 | 17 | <a href="../Tiny_httpd_core/Server/index.html#type-upgrade_handler">Tiny_httpd_core.Server.upgrade_handler</a>)</span> |
16 | 18 | <a href="../Tiny_httpd_core/Route/index.html#type-t">Tiny_httpd_core.Route.t</a></span> <span class="arrow">-></span></span> |
17 | 19 | <span><a href="#type-handler">handler</a> <span class="arrow">-></span></span> |
18 | | - unit</span></code></div><div class="spec-doc"><p>Add a route handler for a websocket endpoint.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">accept_ws_protocol</span> <p>decides whether this endpoint accepts the websocket protocol sent by the client. Default accepts everything.</p></li></ul></div></div></div></body></html> |
| 20 | + unit</span></code></div><div class="spec-doc"><p>Add a route handler for a websocket endpoint.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">accept_ws_protocol</span> <p>decides whether this endpoint accepts the websocket protocol sent by the client. Default accepts everything.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">with_lock</span> <p>if provided, use this to synchronize writes between the frame reader (replies "pong" to "ping") and the handler emitting writes. since NEXT_RELEASE.</p></li></ul></div></div></div></body></html> |
0 commit comments