Deployed 73b9c0b with MkDocs version: 1.1.2

This commit is contained in:
2020-08-28 21:56:23 +00:00
parent 2fbf0e49ca
commit 8b5d0d7114
6 changed files with 23 additions and 20 deletions

View File

@ -361,10 +361,9 @@ ix::WebSocketServer server(port);
server.setOnConnectionCallback(
[&server](std::weak_ptr<WebSocket> webSocket,
std::shared_ptr<ConnectionState> connectionState,
std::unique_ptr<ConnectionInfo> connectionInfo)
std::shared_ptr<ConnectionState> connectionState)
{
std::cout << "Remote ip: " << connectionInfo->remoteIp << std::endl;
std::cout << "Remote ip: " << connectionState->remoteIp << std::endl;
auto ws = webSocket.lock();
if (ws)
@ -436,13 +435,12 @@ server.wait();
ix::WebSocketServer server(port);
server.setOnClientMessageCallback(std::shared_ptr<ConnectionState> connectionState,
ConnectionInfo& connectionInfo,
WebSocket& webSocket,
const WebSocketMessagePtr& msg)
{
// The ConnectionInfo object contains information about the connection,
// The ConnectionState object contains information about the connection,
// at this point only the client ip address and the port.
std::cout << "Remote ip: " << connectionInfo.remoteIp << std::endl;
std::cout << "Remote ip: " << connectionState->getRemoteIp();
if (msg->type == ix::WebSocketMessageType::Open)
{
@ -589,12 +587,11 @@ server.wait();
<p>If you want to handle how requests are processed, implement the setOnConnectionCallback callback, which takes an HttpRequestPtr as input, and returns an HttpResponsePtr. You can look at HttpServer::setDefaultConnectionCallback for a slightly more advanced callback example.</p>
<pre><code class="cpp">setOnConnectionCallback(
[this](HttpRequestPtr request,
std::shared_ptr&lt;ConnectionState&gt; /*connectionState*/,
std::unique_ptr&lt;ConnectionInfo&gt; connectionInfo) -&gt; HttpResponsePtr
std::shared_ptr&lt;ConnectionState&gt; connectionState) -&gt; HttpResponsePtr
{
// Build a string for the response
std::stringstream ss;
ss &lt;&lt; connectionInfo-&gt;remoteIp
ss &lt;&lt; connectionState-&gt;getRemoteIp();
&lt;&lt; &quot; &quot;
&lt;&lt; request-&gt;method
&lt;&lt; &quot; &quot;