Deployed 847fc14 with MkDocs version: 1.1.2
This commit is contained in:
parent
9e0825127d
commit
b47cb43419
@ -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="#1000-2020-07-25" class="nav-link">[10.0.0] - 2020-07-25</a>
|
||||
<ul class="nav flex-column">
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item" data-level="2"><a href="#9107-2020-07-25" class="nav-link">[9.10.7] - 2020-07-25</a>
|
||||
<ul class="nav flex-column">
|
||||
</ul>
|
||||
@ -880,6 +884,8 @@
|
||||
|
||||
<h1 id="changelog">Changelog</h1>
|
||||
<p>All changes to this project will be documented in this file.</p>
|
||||
<h2 id="1000-2020-07-25">[10.0.0] - 2020-07-25</h2>
|
||||
<p>(ixwebsocket server) change legacy api with 2 nested callbacks, so that the first api takes a weak_ptr<WebSocket> as its first argument</p>
|
||||
<h2 id="9107-2020-07-25">[9.10.7] - 2020-07-25</h2>
|
||||
<p>(ixwebsocket) add WebSocketProxyServer, from ws. Still need to make the interface better.</p>
|
||||
<h2 id="9106-2020-07-24">[9.10.6] - 2020-07-24</h2>
|
||||
|
@ -262,5 +262,5 @@ webSocket.send("hello world");
|
||||
|
||||
<!--
|
||||
MkDocs version : 1.1.2
|
||||
Build Date UTC : 2020-07-25 18:26:57.024903+00:00
|
||||
Build Date UTC : 2020-07-25 18:43:04.491489+00:00
|
||||
-->
|
||||
|
File diff suppressed because one or more lines are too long
BIN
sitemap.xml.gz
BIN
sitemap.xml.gz
Binary file not shown.
@ -331,6 +331,7 @@ uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
|
||||
|
||||
<h2 id="websocket-server-api">WebSocket server API</h2>
|
||||
<h3 id="legacy-api">Legacy api</h3>
|
||||
<p>This api was actually changed to take a weak_ptr<WebSocket> as the first argument to setOnConnectionCallback ; previously it would take a shared_ptr<WebSocket> which was creating cycles and then memory leaks problems.</p>
|
||||
<pre><code class="cpp">#include <ixwebsocket/IXWebSocketServer.h>
|
||||
|
||||
...
|
||||
@ -340,41 +341,49 @@ uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
|
||||
ix::WebSocketServer server(port);
|
||||
|
||||
server.setOnConnectionCallback(
|
||||
[&server](std::shared_ptr<WebSocket> webSocket,
|
||||
[&server](std::weak_ptr<WebSocket> webSocket,
|
||||
std::shared_ptr<ConnectionState> connectionState,
|
||||
std::unique_ptr<ConnectionInfo> connectionInfo)
|
||||
{
|
||||
std::cout << "Remote ip: " << connectionInfo->remoteIp << std::endl;
|
||||
|
||||
webSocket->setOnMessageCallback(
|
||||
[webSocket, connectionState, &server](const ix::WebSocketMessagePtr msg)
|
||||
{
|
||||
if (msg->type == ix::WebSocketMessageType::Open)
|
||||
auto ws = webSocket.lock();
|
||||
if (ws)
|
||||
{
|
||||
ws->setOnMessageCallback(
|
||||
[webSocket, connectionState, &server](const ix::WebSocketMessagePtr msg)
|
||||
{
|
||||
std::cout << "New connection" << 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 << "id: " << connectionState->getId() << std::endl;
|
||||
|
||||
// The uri the client did connect to.
|
||||
std::cout << "Uri: " << msg->openInfo.uri << std::endl;
|
||||
|
||||
std::cout << "Headers:" << std::endl;
|
||||
for (auto it : msg->openInfo.headers)
|
||||
if (msg->type == ix::WebSocketMessageType::Open)
|
||||
{
|
||||
std::cout << it.first << ": " << it.second << std::endl;
|
||||
std::cout << "New connection" << 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 << "id: " << connectionState->getId() << std::endl;
|
||||
|
||||
// The uri the client did connect to.
|
||||
std::cout << "Uri: " << msg->openInfo.uri << std::endl;
|
||||
|
||||
std::cout << "Headers:" << std::endl;
|
||||
for (auto it : msg->openInfo.headers)
|
||||
{
|
||||
std::cout << it.first << ": " << it.second << std::endl;
|
||||
}
|
||||
}
|
||||
else if (msg->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.
|
||||
auto ws = webSocket.lock();
|
||||
if (ws)
|
||||
{
|
||||
ws->send(msg->str, msg->binary);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg->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->str, msg->binary);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user