components/websocket/include/websocket_server.h

changeset 30
3cc32f97410c
parent 0
b74b0e4902c3
equal deleted inserted replaced
29:45647136ec95 30:3cc32f97410c
11 #ifndef WEBSOCKET_SERVER_H 11 #ifndef WEBSOCKET_SERVER_H
12 #define WEBSOCKET_SERVER_H 12 #define WEBSOCKET_SERVER_H
13 13
14 #include "websocket.h" 14 #include "websocket.h"
15 15
16 #define WEBSOCKET_SERVER_MAX_CLIENTS CONFIG_WEBSOCKET_SERVER_MAX_CLIENTS 16 #define WEBSOCKET_SERVER_MAX_CLIENTS CONFIG_WEBSOCKET_SERVER_MAX_CLIENTS ///< Maximum allowed clients
17 #define WEBSOCKET_SERVER_QUEUE_SIZE CONFIG_WEBSOCKET_SERVER_QUEUE_SIZE 17 #define WEBSOCKET_SERVER_QUEUE_SIZE CONFIG_WEBSOCKET_SERVER_QUEUE_SIZE ///< Webserver requests queue size
18 #define WEBSOCKET_SERVER_QUEUE_TIMEOUT CONFIG_WEBSOCKET_SERVER_QUEUE_TIMEOUT 18 #define WEBSOCKET_SERVER_QUEUE_TIMEOUT CONFIG_WEBSOCKET_SERVER_QUEUE_TIMEOUT ///< Queue timeout
19 #define WEBSOCKET_SERVER_TASK_STACK_DEPTH CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH 19 #define WEBSOCKET_SERVER_TASK_STACK_DEPTH CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH ///< Task stack size
20 #define WEBSOCKET_SERVER_TASK_PRIORITY CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY 20 #define WEBSOCKET_SERVER_TASK_PRIORITY CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY ///< Task priority
21 #define WEBSOCKET_SERVER_PINNED CONFIG_WEBSOCKET_SERVER_PINNED 21 #define WEBSOCKET_SERVER_PINNED CONFIG_WEBSOCKET_SERVER_PINNED ///< Pinned to a CPU
22 #if WEBSOCKET_SERVER_PINNED 22 #if WEBSOCKET_SERVER_PINNED
23 #define WEBSOCKET_SERVER_PINNED_CORE CONFIG_WEBSOCKET_SERVER_PINNED_CORE 23 #define WEBSOCKET_SERVER_PINNED_CORE CONFIG_WEBSOCKET_SERVER_PINNED_CORE ///< If pinned, which CPU
24 #endif 24 #endif
25 25
26 /** 26 /**
27 * @brief Starts the server. 27 * @brief Starts the server.
28 * @return 1 if started, 0 if the server was already started. 28 * @return 1 if started, 0 if the server was already started.
102 102
103 /** 103 /**
104 * @brief Send text to client with the set number. 104 * @brief Send text to client with the set number.
105 * @param num The client connection number. 105 * @param num The client connection number.
106 * @param msg The message to send. 106 * @param msg The message to send.
107 * @param The length of the message to send. 107 * @param len The length of the message to send.
108 * @retrun 1 if message send. 108 * @return 1 if message send.
109 */ 109 */
110 int ws_server_send_text_client(int num,char* msg,uint64_t len); 110 int ws_server_send_text_client(int num,char* msg,uint64_t len);
111 int ws_server_send_text_client_from_callback(int num,char* msg,uint64_t len); 111 int ws_server_send_text_client_from_callback(int num,char* msg,uint64_t len);
112 112
113 /** 113 /**
114 * @brief Sends text to all clients with the set url. 114 * @brief Sends text to all clients with the set url.
115 * @param url The clients url. 115 * @param url The clients url.
116 * @param msg The message to send. 116 * @param msg The message to send.
117 * @param The length of the message to send. 117 * @param len The length of the message to send.
118 * @return The number of clients the message was send to. 118 * @return The number of clients the message was send to.
119 */ 119 */
120 int ws_server_send_text_clients(char* url,char* msg,uint64_t len); 120 int ws_server_send_text_clients(char* url,char* msg,uint64_t len);
121 int ws_server_send_text_clients_from_callback(char* url,char* msg,uint64_t len); 121 int ws_server_send_text_clients_from_callback(char* url,char* msg,uint64_t len);
122 122
123 /** 123 /**
124 * @brief Sends text to all clients. 124 * @brief Sends text to all clients.
125 * @param msg The message to send. 125 * @param msg The message to send.
126 * @param The length of the message to send. 126 * @param len The length of the message to send.
127 * @return The number of clients the message was send to. 127 * @return The number of clients the message was send to.
128 */ 128 */
129 int ws_server_send_text_all(char* msg,uint64_t len); 129 int ws_server_send_text_all(char* msg,uint64_t len);
130 int ws_server_send_text_all_from_callback(char* msg,uint64_t len); 130 int ws_server_send_text_all_from_callback(char* msg,uint64_t len);
131 131
132 /** 132 /**
133 * @brief Send binary message to client with the set number. 133 * @brief Send binary message to client with the set number.
134 * @param num The client connection number. 134 * @param num The client connection number.
135 * @param msg The message to send. 135 * @param msg The message to send.
136 * @param The length of the message to send. 136 * @param len The length of the message to send.
137 * @retrun 1 if message send. 137 * @return 1 if message send.
138 */ 138 */
139 int ws_server_send_bin_client(int num,char* msg,uint64_t len); 139 int ws_server_send_bin_client(int num,char* msg,uint64_t len);
140 int ws_server_send_bin_client_from_callback(int num,char* msg,uint64_t len); 140 int ws_server_send_bin_client_from_callback(int num,char* msg,uint64_t len);
141 141
142 /** 142 /**
143 * @brief Sends binary message to all clients with the set url. 143 * @brief Sends binary message to all clients with the set url.
144 * @param url The clients url. 144 * @param url The clients url.
145 * @param msg The message to send. 145 * @param msg The message to send.
146 * @param The length of the message to send. 146 * @param len The length of the message to send.
147 * @return The number of clients the message was send to. 147 * @return The number of clients the message was send to.
148 */ 148 */
149 int ws_server_send_bin_clients(char* url,char* msg,uint64_t len); 149 int ws_server_send_bin_clients(char* url,char* msg,uint64_t len);
150 150
151 /** 151 /**
152 * @brief Sends binary message to all clients. 152 * @brief Sends binary message to all clients.
153 * @param msg The message to send. 153 * @param msg The message to send.
154 * @param The length of the message to send. 154 * @param len The length of the message to send.
155 * @return The number of clients the message was send to. 155 * @return The number of clients the message was send to.
156 */ 156 */
157 int ws_server_send_bin_all(char* msg,uint64_t len); 157 int ws_server_send_bin_all(char* msg,uint64_t len);
158 158
159 159 /**
160 int ws_server_ping(int num); // sends a ping to client num 160 * @brief Websocket ping (not working yet)
161 * @param num The connection number
162 * @return 1 if succeeded.
163 */
164 int ws_server_ping(int num);
161 165
162 #endif 166 #endif
163 167
164 #ifdef __cplusplus 168 #ifdef __cplusplus
165 } 169 }

mercurial