Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 订阅WebSocket提要_C++_Websocket - Fatal编程技术网

C++ 订阅WebSocket提要

C++ 订阅WebSocket提要,c++,websocket,C++,Websocket,我正在尝试使用cpprestsdk访问WebSocket API。到目前为止,我的示例代码是: #include <iostream> #include <cpprest/ws_client.h> using namespace std; using namespace web; using namespace web::websockets::client; int main() { websocket_client client; client.conne

我正在尝试使用cpprestsdk访问WebSocket API。到目前为止,我的示例代码是:

#include <iostream>
#include <cpprest/ws_client.h>

using namespace std;
using namespace web;
using namespace web::websockets::client;

int main() {
  websocket_client client;
  client.connect("wss://api.poloniex.com").wait();

  websocket_outgoing_message out_msg;
  out_msg.set_utf8_message("test");
  client.send(out_msg).wait();

  client.receive().then([](websocket_incoming_message in_msg) {
    return in_msg.extract_string();
  }).then([](string body) {
    cout << body << endl; // test
  }).wait();

  client.close().wait();

  return 0;
}
#包括
#包括
使用名称空间std;
使用命名空间web;
使用名称空间web::websockets::client;
int main(){
websocket_客户端;
客户端连接(“wss://api.poloniex.com)等等;
websocket\u传出消息\u消息;
输出消息设置utf8消息(“测试”);
client.send(out_msg.wait();
client.receive()。然后([](websocket\u消息中的传入消息){
返回_msg.extract_string();
})。然后([](字符串体){

这是一个关于Poloniex的问题,而不是关于WebSocket本身的问题。(你需要知道发送什么而不是“测试”)啊,好吧,我认为订阅是WebSocket常用的一个词。这是一个关于Poloniex的问题,而不是关于WebSocket本身的问题。(你需要知道发送什么而不是“测试”)啊,好吧,我想订阅是WebSocket中常用的一个词。