website/docs/ddoc/websockets/handy_http_websockets.handl...

44 lines
6.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>WebSocketRequestHandler (handy_http_websockets.handler.WebSocketRequestHandler)</title>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="style.css" rel="stylesheet" />
<script src="script.js" type="text/javascript"></script>
<link href="search-results.html" rel="prefetch" />
</head>
<body>
<div id="page-header">
<div id="logotype">
<span>Documentation</span>
<nav>
<a href="http://dlang.org/">Dlang.org</a>
</nav>
</div>
<form action="search-docs.html" id="search">
<input name="searchTerm" placeholder="Find a symbol name..." type="search" />
<input type="submit" value="Go" />
</form>
</div>
<div id="page-body">
<div id="page-content">
<h1>WebSocketRequestHandler</h1><div class="breadcrumbs"><a class="breadcrumb" href="handy_http_websockets.html">handy_http_websockets</a> <a class="breadcrumb" href="handy_http_websockets.handler.html">handler</a> </div><div><div class="documentation-comment synopsis"><div><p>An HTTP request handler implementation that's used as the entrypoint for
clients that want to establish a websocket connection. It will verify the
websocket request, and if successful, send back a SWITCHING_PROTOCOLS
response, and register a new websocket connection.</p></div></div></div><div class="annotated-prototype"><div class="aggregate-prototype"><div class="attributes"></div><span class="builtin-type">class</span> WebSocketRequestHandler : HttpRequestHandler {<div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.this.html"><span class="lang-feature name">this</span>(WebSocketMessageHandler messageHandler);</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.handle.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">handle</span>(ServerHttpRequest request, ServerHttpResponse response);</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.connectionCount.html"><tt class="highlighted"><span class="hid">size_t</span></tt> <span class="name">connectionCount</span>();</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.addConnection.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">addConnection</span>(WebSocketConnection conn, ServerHttpRequest request);</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.removeConnection.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">removeConnection</span>(WebSocketConnection conn);</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.broadcast.1.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">broadcast</span>(string text);</a></div><div class="aggregate-member"><a href="handy_http_websockets.handler.WebSocketRequestHandler.broadcast.2.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">broadcast</span>(ubyte[] data);</a></div>}</div></div><h2 id="constructors"><a class="header-anchor" href="#constructors">Constructors</a></h2><dl class="member-list constructors"><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.this.html">this</a><div class="simplified-prototype" style="max-width: 48ch;"><span class="lang-feature name">this</span>(WebSocketMessageHandler messageHandler)</div></dt><dd><div><p>Constructs a request handler that will use the given message handler to
deal with events from any websocket connections that are established.</p></div></dd></dl><h2 id="members"><a class="header-anchor" href="#members">Members</a></h2><h3 class="member-list-header hide-from-toc" id="function"><a class="header-anchor" href="#function">Functions</a></h3><dl class="member-list native"><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.addConnection.html">addConnection</a><div class="simplified-prototype" style="max-width: 78ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">addConnection</span>(WebSocketConnection conn, ServerHttpRequest request)</div></dt><dd><div><p>Adds a connection to the manager and starts listening for messages.</p></div></dd><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.broadcast.2.html">broadcast</a><div class="simplified-prototype" style="max-width: 30ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">broadcast</span>(ubyte[] data)</div></dt><dd><div><p>Broadcasts a binary message to all connected clients.</p></div></dd><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.broadcast.1.html">broadcast</a><div class="simplified-prototype" style="max-width: 29ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">broadcast</span>(string text)</div></dt><dd><div><p>Broadcasts a message to all connected clients.</p></div></dd><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.connectionCount.html">connectionCount</a><div class="simplified-prototype" style="max-width: 26ch;"><tt class="highlighted"><span class="hid">size_t</span></tt> <span class="name">connectionCount</span>()</div></dt><dd><div><p>Gets the number of active connections.</p></div></dd><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.handle.html">handle</a><div class="simplified-prototype" style="max-width: 73ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">handle</span>(ServerHttpRequest request, ServerHttpResponse response)</div></dt><dd><div><p>Handles an incoming HTTP request and tries to establish a websocket
connection by first verifying the request, then sending a switching-
protocols response, and finally registering the new connection with the
websocket manager.</p></div></dd><dt><a href="handy_http_websockets.handler.WebSocketRequestHandler.removeConnection.html">removeConnection</a><div class="simplified-prototype" style="max-width: 51ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">removeConnection</span>(WebSocketConnection conn)</div></dt><dd><div><p>Removes a websocket connection from the manager and closes it. This is
called automatically if the client sends a CLOSE frame, but you can also
call it yourself.</p></div></dd></dl><div></div></div>
<div id="page-nav"><a class="parent" href="handy_http_websockets.html">handy_http_websockets</a> <a class="parent" href="handy_http_websockets.handler.html">handler</a>
<span class="type-separator">classes</span><ul><li><a class="class current" href="handy_http_websockets.handler.WebSocketRequestHandler.html">WebSocketRequestHandler</a></li></ul></div>
</div>
<div id="page-footer">Page generated by <a href="https://github.com/adamdruppe/adrdox">adrdox</a></div>
</body>
</html>