您当前的位置: 首页 >  websocket

qianbo_insist

暂无认证

  • 0浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

websocketpp 最简单的客户端 一

qianbo_insist 发布时间:2021-07-21 08:46:57 ,浏览量:0

websocket 服务端

简单服务端在这里

websocketpp 客户端

客户端并没有做断线重连,这个有兴趣的可以自己实现,下一章会实现的。几个预定义的还是要写,例如不想用boost,直接用asio,还是要定义ASIO_STANDALONE,其他的太简单,多熟悉官方的例子就好


#define _CRT_SECURE_NO_WARNINGS
#define _WEBSOCKETPP_CPP11_TYPE_TRAITS_
#define _SCL_SECURE_NO_WARNINGS
#define ASIO_STANDALONE
#include 
#include 

#include 

typedef websocketpp::client client;

using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;

// pull out the type of messages sent by our config
typedef websocketpp::config::asio_client::message_type::ptr message_ptr;

// This message handler will be invoked once for each incoming message. It
// prints the message and then sends a copy of the message back to the server.
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
	std::cout             
关注
打赏
1663161521
查看更多评论
0.2056s