1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __UVOICE_WS_H__ 6 #define __UVOICE_WS_H__ 7 8 9 typedef enum { 10 WS_BIN_DATA_START, 11 WS_BIN_DATA_CONTINUE, 12 WS_BIN_DATA_FINISH, 13 } ws_bin_type_t; 14 15 typedef struct { 16 void (*connect_cb)(void); 17 void (*disconnect_cb)(void); 18 void (*recv_text_cb)(char *text, int size); 19 void (*recv_binary_cb)(char *data, int size, ws_bin_type_t type); 20 } ws_cb_ops_t; 21 22 typedef struct { 23 uint16_t port; 24 char *server; 25 char *schema; 26 char *cacert; 27 char *path; 28 ws_cb_ops_t callback; 29 } ws_conn_info_t; 30 31 typedef enum { 32 WS_CONN_STAT_DISCONNECTED = 0, 33 WS_CONN_STAT_CONNECTING, 34 WS_CONN_STAT_CONNECTED, 35 } ws_conn_state_t; 36 37 #if (UVOICE_WS_ENABLE == 1) 38 int uvoice_ws_connect(ws_conn_info_t *info); 39 int uvoice_ws_disconnect(void); 40 int uvoice_ws_conn_state(ws_conn_state_t *state); 41 int uvoice_ws_send_text(char *text, int len); 42 int uvoice_ws_send_binary(char *data, int len, ws_bin_type_t type); 43 int uvoice_ws_recv_pause(int pause); 44 int uvoice_ws_heartbeat_set(int type); 45 int uvoice_ws_init(void); 46 int uvoice_ws_deinit(void); 47 #endif 48 49 50 #endif /*__UVOICE_WS_H__*/ 51 52