代码拉取完成,页面将自动刷新
#pragma once
#include <inttypes.h>
#include <event.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/listener.h>
#include <event2/util.h>
#include <event2/event.h>
#include <event2/dns.h>
#include <event2/thread.h>
#include <evhttp.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define LIBWS_OP_CONTINUE 0
#define LIBWS_OP_TEXT 1
#define LIBWS_OP_BINARY 2
#define LIBWS_OP_CLOSE 8
#define LIBWS_OP_PING 9
#define LIBWS_OP_PONG 10
#define LIBWS_FLAGS_MASK_FIN 128
#define LIBWS_FLAGS_MASK_OP 15
#define LIBWS_ADD_HEAD(type_, head_, elem_) \
do { \
(elem_)->next = (*head_); \
*(head_) = (elem_); \
} while (0)
#define LIBWS_ADD_TAIL(type_, head_, elem_) \
do { \
type_ **h = head_; \
while (*h != NULL) h = &(*h)->next; \
*h = (elem_); \
} while (0)
#define LIBWS_DELETE(type_, head_, elem_) \
do { \
type_ **h = head_; \
while (*h != (elem_)) h = &(*h)->next; \
*h = (elem_)->next; \
} while (0)
struct libws_t;
typedef struct libws_t *(*new_conn_cb)(struct evhttp_request *req);
typedef int (*libws_conn)(struct libws_t*);
typedef int (*libws_disconn)(struct libws_t*);
typedef int (*libws_data)(struct libws_t*, uint8_t *,size_t);
struct libws_t
{
struct libws_t *next;
libws_conn conn_cb;
libws_disconn disconn_cb;
libws_data rd_cb;
libws_conn wr_cb;
struct evhttp_connection *conn;
uint64_t ms;
int is_active:1; // 是否可用
int is_client:1; // 是不是客户端,用来发送MASK位
int fin:1; // FIN位
};
int libws_send(struct libws_t*pws, uint8_t*pdata, size_t size, uint8_t op);
struct libws_t *libws_connect(struct event_base *base,
const char *url,
struct evkeyvalq *exheader,
libws_data rd, libws_conn wr, libws_conn con,libws_disconn clo);
void init_libws();
void destory_libws();
void set_new_ws(new_conn_cb);
void libws_poll();
#ifdef __cplusplus
}
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。