从c ++应用程序连接到socket.io服务器

Fir*_*ame 10 c++ node.js socket.io

我正在尝试为我的基于Web的应用程序做poc,我有以下内容

1)LINUX上基于node.js/socket.io的基本服务器,它将基本网页作为客户端提供服务

client.html

<!DOCTYPE html>
<html>
<head>
    <script src="/socket.io/socket.io.js"></script>
    <script type="text/javascript">

     var socket = io.connect("169.xxx.xxx.xx:5000");

     socket.on("aServerEvent", function(data)
     {
       document.getElementById("chatlog").innerHTML = ("<hr/>" +
       data['message'] + document.getElementById("chatlog").innerHTML);
     });

     function sendMessage()
     {
        var msg = document.getElementById("message_input").value;
        socket.emit("aClientEvent", { message : msg});
     }
    </script>
</head>

<body>

    <input type="text" id="message_input"/>
    <button onclick="sendMessage()">send</button>
    <div id="chatlog"></div>

</body>

</html>
Run Code Online (Sandbox Code Playgroud)

server.js

var app = require('http').createServer(handler),
    io = require('socket.io').listen(app),
    fs = require('fs')
    app.listen(5000,'169.xxx.xxx.xx');

function handler (req, res)
{
    fs.readFile("client.html", function (err, data)
    {
        if (err)
        {
            res.writeHead(500);
            return res.end('Error loading client.html');
        }
        res.writeHead(200);
        res.end(data);
    });
}

console.log('Server running at http://169.xxx.xxx.xx:5000/');

io.sockets.on('connection', function(socket)
{
    socket.on('aClientEvent', function(data)
    {
        var newData = "serverResponse: " + data["message"].toUpperCase();
        io.sockets.emit("aServerEvent", { message: newData });
    });
});
Run Code Online (Sandbox Code Playgroud)

到目前为止,我在网页(客户端)上输入了一个文本,该文本由服务器读取,返回大写文本作为确认.

2)现在我想在linux上编写一个基本的C++程序,使用websocketpp与我的node.js/socket.io服务器建立基于websocket的连接

最好的方法是什么,即如何在node.js服务器和c ++应用程序(基于websocketpp)之间建立基于websocket的连接?

我找到的最接近的比赛是......

https://github.com/ebshimizu/socket.io-clientpp 
Run Code Online (Sandbox Code Playgroud)

(但是使用rapidjson,我只想使用libjson)

https://github.com/uning/socket.io-client-cpp 
Run Code Online (Sandbox Code Playgroud)

(这看起来像原始websocketpp库的修改版本,并且在src中有很多文件,如果需要所有这些文件会让我感到困惑)

任何指针都会被贬低

提前致谢

jkl*_*mnn 0

由于您运行的是 Linux,因此应该有一个用于此目的的软件包。我查看了 Debian,websocketpp-dev 正是您所需要的。只需尝试yum search websocketppapt-get search websocketpp安装 devel/dev 包即可。
该文档可以在这里找到: http: //doxygen.websocketpp.org/annotated.html
我希望这就是您正在寻找的内容。