C++ websocket客户端没有接收回调
我们有一个用 C# 编写的 WebSocket 服务器和客户端。服务器被设计为根据客户端读取和处理消息的快/慢来减慢速度。 C# 客户端一次读取一条消息。
我正在寻找用 C++ 编写一个客户端,到目前为止我查看的所有库都有一个用于从服务器接收消息的消息处理程序或回调机制。
这意味着客户端连续接收消息,将其排队,然后客户端从队列中读取消息。这不是我们正在寻找的行为。我们要求客户端读取一条消息并处理它,处理完成后,读取下一条消息。我们可以使用任何可用的库来实现这一目标吗?
到目前为止我已经检查了 cpprestsdk、websocketpp、libwebsocket
We've a WebSocket server and clients in C#. The server is designed to slow down depending on how fast/slow the client reads and processes the messages. The C# clients reads one message at a time.
I'm looking to write a client in c++ and all the libraries I looked so far have a message handler or callback mechanism for receiving message from server.
This would mean that the client is receiving messages continuously, queue it and the client reads from the queue. This is not the behavior we're looking for. We require the client to read a message and process it and once the processing is complete, read the next message. Is there any library available we could use to achieve this?
I've so far checked cpprestsdk, websocketpp, libwebsocket
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Boost.ASIO 库。
我制作了一个可以使用 Websocket 和多个连接的服务器。每个连接都使用异步方式接收数据,这些数据将在接收下一条消息之前进行处理:
在此示例中,连接可以是普通连接,也可以是安全连接,使用 SSL,两者都使用 lambda 函数来接收数据。
我在浏览器上使用 JS 应用程序测试了此服务,并且处理每条消息的顺序没有问题。
you can use Boost.ASIO Library.
I made a server that works with Websocket and multiple connections. Each connection uses an asynchronous way to receive data which will be handled before receiving the next message:
In this sample the connection could be plain or secure, using SSL, both of them are using a lambda function to receive the data.
I tested this service with a JS application, on the browser and there is no problem with the sequence to attend each message.