Soletta™ Framework
|
HTTP Server sse. More...
#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "soletta.h"
#include "sol-http.h"
#include "sol-http-server.h"
#include "sol-util.h"
#include "sol-util-file.h"
Macros | |
#define | HTML_FILE |
Functions | |
static void | delete_cb (void *data, const struct sol_http_progressive_response *sse) |
static void | on_feed_done_cb (void *data, struct sol_http_progressive_response *sse, struct sol_blob *blob, int status) |
static bool | on_stdin (void *data, int fd, uint32_t flags) |
static int | request_cb (void *data, struct sol_http_request *request) |
static int | request_events_cb (void *data, struct sol_http_request *request) |
static void | shutdown_server (void) |
SOL_MAIN_DEFAULT (startup_server, shutdown_server) | |
static void | startup_server (void) |
Variables | |
static int | port = 8080 |
static struct sol_ptr_vector | responses = SOL_PTR_VECTOR_INIT |
static struct sol_http_server * | server |
static bool | should_quit = false |
static struct sol_fd * | stdin_watch |
HTTP Server sse.
Sample server that return a response and keep it alive. It implements server sent events. The server sends the data typed in stdin and the data is broadcasted to all the clients connected.
To test it:
run ./server-sse -p 8080 open a browser in http://127.0.0.1:8080 or curl http://127.0.0.1:8080 type something
To see the usage help, -h or –help.
#define HTML_FILE |
Referenced by request_cb().
|
static |
References should_quit, sol_ptr_vector_get_len(), sol_ptr_vector_remove(), and sol_quit().
Referenced by request_events_cb().
|
static |
References sol_str_slice::data, sol_str_slice::len, sol_str_slice_from_blob(), SOL_STR_SLICE_PRINT, and sol_str_slice_str_eq().
Referenced by request_events_cb().
|
static |
References should_quit, sol_blob_unref(), sol_buffer_fini(), SOL_BUFFER_INIT_EMPTY, sol_buffer_to_blob(), sol_http_progressive_response_del(), sol_http_progressive_response_sse_feed(), SOL_PTR_VECTOR_FOREACH_IDX, sol_quit_with_code(), sol_util_load_file_fd_buffer(), sol_util_strerrora, stdin_watch, and sol_buffer::used.
Referenced by startup_server().
|
static |
References sol_http_response::api_version, sol_http_response::content, HTML_FILE, sol_network_link_addr::port, sol_buffer_append_printf(), SOL_BUFFER_DECLARE_STATIC, sol_buffer_fini(), sol_buffer_get_slice(), sol_buffer_init(), sol_http_request_get_interface_address(), SOL_HTTP_REQUEST_PARAMS_INIT, SOL_HTTP_RESPONSE_API_VERSION, sol_http_server_send_response(), SOL_HTTP_STATUS_OK, SOL_INT_CHECK, SOL_NETWORK_INET_ADDR_STR_LEN, sol_network_link_addr_to_str(), SOL_NULL_CHECK, SOL_SET_API_VERSION, and SOL_STR_SLICE_PRINT.
Referenced by startup_server().
|
static |
References sol_http_response::api_version, sol_http_server_progressive_config::api_version, delete_cb(), on_feed_done_cb(), sol_http_response::param, SOL_BUFFER_INIT_EMPTY, sol_http_params_clear(), sol_http_progressive_response_del(), SOL_HTTP_REQUEST_PARAMS_INIT, SOL_HTTP_RESPONSE_API_VERSION, sol_http_response_set_sse_headers(), SOL_HTTP_SERVER_PROGRESSIVE_CONFIG_API_VERSION, sol_http_server_send_progressive_response(), SOL_HTTP_STATUS_OK, sol_ptr_vector_append(), and SOL_SET_API_VERSION.
Referenced by startup_server().
|
static |
SOL_MAIN_DEFAULT | ( | startup_server | , |
shutdown_server | |||
) |
|
static |
|
static |
Referenced by main(), and startup_server().
|
static |
|
static |
Referenced by shutdown_server(), and startup_server().
|
static |
Referenced by delete_cb(), and on_stdin().
|
static |
Referenced by on_stdin(), shutdown_server(), and startup_server().