Deployed 2798886 with MkDocs version: 1.1.2

This commit is contained in:
2020-07-24 02:30:29 +00:00
parent 1bff15e048
commit 8d743c5264
6 changed files with 81 additions and 10 deletions

View File

@ -95,6 +95,10 @@
<li class="nav-item" data-level="1"><a href="#changelog" class="nav-link">Changelog</a>
<ul class="nav flex-column">
<li class="nav-item" data-level="2"><a href="#9100-2020-07-23" class="nav-link">[9.10.0] - 2020-07-23</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#993-2020-07-17" class="nav-link">[9.9.3] - 2020-07-17</a>
<ul class="nav flex-column">
</ul>
@ -852,6 +856,8 @@
<h1 id="changelog">Changelog</h1>
<p>All changes to this project will be documented in this file.</p>
<h2 id="9100-2020-07-23">[9.10.0] - 2020-07-23</h2>
<p>(websocket server) add a new simpler API to handle client connections / that API does not trigger a memory leak while the previous one did</p>
<h2 id="993-2020-07-17">[9.9.3] - 2020-07-17</h2>
<p>(build) merge platform specific files which were used to have different implementations for setting a thread name into a single file, to make it easier to include every source files and build the ixwebsocket library (fix #226)</p>
<h2 id="992-2020-07-10">[9.9.2] - 2020-07-10</h2>

View File

@ -262,5 +262,5 @@ webSocket.send(&quot;hello world&quot;);
<!--
MkDocs version : 1.1.2
Build Date UTC : 2020-07-17 18:59:10.766805+00:00
Build Date UTC : 2020-07-24 02:30:29.533927+00:00
-->

File diff suppressed because one or more lines are too long

View File

@ -1,35 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>None</loc>
<lastmod>2020-07-17</lastmod>
<lastmod>2020-07-24</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.

View File

@ -330,6 +330,7 @@ uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
</code></pre>
<h2 id="websocket-server-api">WebSocket server API</h2>
<h3 id="legacy-api">Legacy api</h3>
<pre><code class="cpp">#include &lt;ixwebsocket/IXWebSocketServer.h&gt;
...
@ -395,6 +396,70 @@ server.wait();
</code></pre>
<h3 id="new-api">New api</h3>
<p>The new API does not require to use 2 nested callbacks, which is a bit annoying. The real fix is that there was a memory leak due to a shared_ptr cycle, due to passing down a shared_ptr<WebSocket> down to the callbacks.</p>
<p>The webSocket reference is guaranteed to be always valid ; by design the callback will never be invoked with a null webSocket object.</p>
<pre><code class="cpp">#include &lt;ixwebsocket/IXWebSocketServer.h&gt;
...
// Run a server on localhost at a given port.
// Bound host name, max connections and listen backlog can also be passed in as parameters.
ix::WebSocketServer server(port);
server.setOnClientMessageCallback(std::shared_ptr&lt;ConnectionState&gt; connectionState,
ConnectionInfo&amp; connectionInfo,
WebSocket&amp; webSocket,
const WebSocketMessagePtr&amp; msg)
{
// The ConnectionInfo object contains information about the connection,
// at this point only the client ip address and the port.
std::cout &lt;&lt; &quot;Remote ip: &quot; &lt;&lt; connectionInfo.remoteIp &lt;&lt; std::endl;
if (msg-&gt;type == ix::WebSocketMessageType::Open)
{
std::cout &lt;&lt; &quot;New connection&quot; &lt;&lt; std::endl;
// A connection state object is available, and has a default id
// You can subclass ConnectionState and pass an alternate factory
// to override it. It is useful if you want to store custom
// attributes per connection (authenticated bool flag, attributes, etc...)
std::cout &lt;&lt; &quot;id: &quot; &lt;&lt; connectionState-&gt;getId() &lt;&lt; std::endl;
// The uri the client did connect to.
std::cout &lt;&lt; &quot;Uri: &quot; &lt;&lt; msg-&gt;openInfo.uri &lt;&lt; std::endl;
std::cout &lt;&lt; &quot;Headers:&quot; &lt;&lt; std::endl;
for (auto it : msg-&gt;openInfo.headers)
{
std::cout &lt;&lt; it.first &lt;&lt; &quot;: &quot; &lt;&lt; it.second &lt;&lt; std::endl;
}
}
else if (msg-&gt;type == ix::WebSocketMessageType::Message)
{
// For an echo server, we just send back to the client whatever was received by the server
// All connected clients are available in an std::set. See the broadcast cpp example.
// Second parameter tells whether we are sending the message in binary or text mode.
// Here we send it in the same mode as it was received.
webSocket.send(msg-&gt;str, msg-&gt;binary);
}
);
auto res = server.listen();
if (!res.first)
{
// Error handling
return 1;
}
// Run the server in the background. Server can be stoped by calling server.stop()
server.start();
// Block until server.stop() is called.
server.wait();
</code></pre>
<h2 id="http-client-api">HTTP client API</h2>
<pre><code class="cpp">#include &lt;ixwebsocket/IXHttpClient.h&gt;