2 #include "../acl_cpp_define.hpp" 3 #include "../stream/aio_socket_stream.hpp" 4 #if !defined(_WIN32) && !defined(_WIN64) 5 #include <netinet/in.h> 20 class aio_socket_stream;
48 virtual void destroy(
void) = 0;
106 return ssl_enable_ && ssl_conf_;
119 bool open(
const char* addr,
int conn_timeout,
int rw_timeout);
131 bool get_ns_addr(
string& out)
const;
138 bool get_server_addr(
string& out)
const;
155 virtual bool on_connect(
void) = 0;
228 this->ws_read_wait(0);
301 void send_request(
const void* body,
size_t len);
308 void ws_handshake(
const void* key,
size_t len);
309 void ws_handshake(
const char* key =
"123456789xxx");
330 void ws_read_wait(
int timeout = 0);
338 bool ws_send_text(
char* data,
size_t len);
346 bool ws_send_binary(
void* data,
size_t len);
354 bool ws_send_ping(
void* data,
size_t len);
362 bool ws_send_pong(
void* data,
size_t len);
369 bool timeout_callback(
void);
372 void close_callback(
void);
375 bool read_wakeup(
void);
378 bool read_callback(
char* data,
int len);
398 struct sockaddr_storage ns_addr_;
399 struct sockaddr_storage serv_addr_;
402 bool handle_ssl_handshake(
void);
404 bool handle_res_hdr(
int status);
406 bool handle_res_body(
char* data,
int dlen);
407 bool res_plain(
char* data,
int dlen);
408 bool res_unzip(
zlib_stream& zstream,
char* data,
int dlen);
410 bool handle_res_body_finish(
char* data,
int dlen);
411 bool res_plain_finish(
char* data,
int dlen);
412 bool res_unzip_finish(
zlib_stream& zstream,
char* data,
int dlen);
414 bool handle_websocket(
void);
415 bool handle_ws_data(
void);
416 bool handle_ws_ping(
void);
417 bool handle_ws_pong(
void);
418 bool handle_ws_other(
void);
422 static int http_res_hdr_cllback(
int status,
void* ctx);
423 static int http_res_callback(
int status,
char* data,
int dlen,
void* ctx);
virtual bool on_ws_handshake(void)
virtual void on_disconnect(void)
virtual bool on_read_timeout(void)
bool is_unzip_body(void) const
aio_socket_stream * conn_
virtual void on_connect_failed(void)
virtual bool on_ws_frame_text(void)
sslbase_conf * get_ssl_conf(void) const
virtual void on_connect_timeout(void)
virtual void ws_handshake_before(http_header &reqhdr)
virtual void on_ns_failed(void)
virtual bool on_ws_frame_finish(void)
virtual void on_ws_frame_closed(void)
virtual bool on_http_res_body(char *data, size_t dlen)
struct ACL_ASTREAM_CTX ACL_ASTREAM_CTX
bool is_enable_ssl(void) const
virtual void on_ws_frame_ping(string &data)
virtual void on_ws_frame_pong(string &data)
virtual void on_ws_handshake_failed(int status)
aio_socket_stream * get_conn(void) const
virtual bool on_ws_frame_data(char *data, size_t dlen)
virtual bool on_http_res_finish(bool success)
virtual bool on_http_res_hdr(const http_header &header)
virtual bool on_ws_frame_binary(void)