![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include <getopt.h>#include <sys/time.h>#include <sys/types.h>#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include "nilorea/n_str.h"#include "nilorea/n_time.h"#include "nilorea/n_network.h"#include "nilorea/n_network_msg.h"#include "nilorea/n_gui.h"
Include dependency graph for ex_gui_network.c:Go to the source code of this file.
Macros | |
| #define | ALLEGRO_UNSTABLE 1 |
| #define | HEIGHT 600 |
| #define | NETMSG_CHAT 100 |
| #define | WIDTH 800 |
Functions | |
| N_STR * | build_chat_msg (const char *text) |
| build a chat network message | |
| void | chat_log_add (const char *text) |
| add a line to the chat log listbox | |
| int | decode_chat_msg (N_STR *str, char **out_text) |
| decode a received chat message | |
| int | main (int argc, char **argv) |
| void | on_send_click (int widget_id, void *user_data) |
| send button callback | |
| void | poll_network_msgs (NETWORK *netw, const char *prefix) |
| process incoming messages on a single network connection | |
| void | refresh_clients_list (void) |
| refresh the connected clients listbox (server only) | |
| void | usage (void) |
Variables | |
| static int | btn_send = -1 |
| ALLEGRO_DISPLAY * | display = NULL |
| static int | DONE = 0 |
| static N_GUI_CTX * | gui = NULL |
| static int | lbl_clients_header = -1 |
| static int | lbl_status = -1 |
| static int | listbox_clients = -1 |
| static int | listbox_log = -1 |
| static int | mode = -1 |
| static NETWORK * | netw_client = NULL |
| static NETWORK * | netw_server = NULL |
| static NETWORK_POOL * | pool = NULL |
| static char * | port_str = NULL |
| static char * | server_addr = NULL |
| static int | textarea_input = -1 |
| static int | win_chat = -1 |
| static int | win_clients = -1 |
| #define ALLEGRO_UNSTABLE 1 |
Definition at line 45 of file ex_gui_network.c.
| #define HEIGHT 600 |
Definition at line 43 of file ex_gui_network.c.
| #define NETMSG_CHAT 100 |
Definition at line 60 of file ex_gui_network.c.
| #define WIDTH 800 |
Definition at line 42 of file ex_gui_network.c.
| N_STR * build_chat_msg | ( | const char * | text | ) |
build a chat network message
| text | the chat text |
Definition at line 130 of file ex_gui_network.c.
References add_int_to_msg(), add_strdup_to_msg(), create_msg(), delete_msg(), make_str_from_msg(), and NETMSG_CHAT.
Referenced by on_send_click(), and poll_network_msgs().
Here is the call graph for this function:
Here is the caller graph for this function:| void chat_log_add | ( | const char * | text | ) |
add a line to the chat log listbox
| text | the text to add |
Definition at line 92 of file ex_gui_network.c.
References gui, listbox_log, and n_gui_listbox_add_item().
Referenced by main(), on_send_click(), and poll_network_msgs().
Here is the call graph for this function:
Here is the caller graph for this function:| int decode_chat_msg | ( | N_STR * | str, |
| char ** | out_text | ||
| ) |
decode a received chat message
| str | the serialized message |
| out_text | output: allocated chat text (caller must Free) |
Definition at line 149 of file ex_gui_network.c.
References delete_msg(), get_int_from_msg(), get_str_from_msg(), make_msg_from_str(), and NETMSG_CHAT.
Referenced by poll_network_msgs().
Here is the call graph for this function:
Here is the caller graph for this function:| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 258 of file ex_gui_network.c.
References btn_send, chat_log_add(), display, DONE, getoptret, gui, HEIGHT, HT_FOREACH, N_SOCKET::ip, lbl_clients_header, lbl_status, NETWORK::link, list_destroy(), list_foreach, listbox_clients, listbox_log, LOG_DEBUG, LOG_ERR, LOG_INFO, log_level, LOG_NOTICE, MAX_LIST_ITEMS, mode, n_gui_add_button(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_textarea(), n_gui_add_window(), N_GUI_ALIGN_LEFT, n_gui_button_set_keycode(), n_gui_draw(), n_gui_label_set_text(), n_gui_new_ctx(), n_gui_process_event(), N_GUI_SELECT_NONE, n_gui_set_display_size(), N_GUI_SHAPE_ROUNDED, N_GUI_WIN_FIXED_POSITION, N_GUI_WIN_RESIZABLE, n_gui_window_set_flags(), n_log, netw_accept_from_ex(), netw_client, netw_close(), netw_connect(), NETW_ERROR, NETW_EXITED, netw_get_state(), netw_make_listening(), netw_new_pool(), netw_pool_add(), netw_pool_nbclients(), netw_pool_remove(), netw_server, netw_set_blocking(), netw_start_thr_engine(), NETWORK_IPALL, new_generic_list(), on_send_click(), poll_network_msgs(), pool, NETWORK_POOL::pool, N_SOCKET::port, port_str, refresh_clients_list(), server_addr, set_log_level(), textarea_input, usage(), WIDTH, win_chat, and win_clients.
Here is the call graph for this function:| void on_send_click | ( | int | widget_id, |
| void * | user_data | ||
| ) |
send button callback
| widget_id | the button widget id |
| user_data | unused |
Definition at line 187 of file ex_gui_network.c.
References build_chat_msg(), chat_log_add(), free_nstr, gui, mode, n_gui_textarea_get_text(), n_gui_textarea_set_text(), netw_add_msg(), netw_client, netw_pool_broadcast(), nstrdup(), pool, and textarea_input.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void poll_network_msgs | ( | NETWORK * | netw, |
| const char * | prefix | ||
| ) |
process incoming messages on a single network connection
| netw | the network to poll |
| prefix | label prefix for log display |
Definition at line 222 of file ex_gui_network.c.
References build_chat_msg(), chat_log_add(), decode_chat_msg(), Free, free_nstr, mode, netw, netw_get_msg(), netw_pool_broadcast(), and pool.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void refresh_clients_list | ( | void | ) |
refresh the connected clients listbox (server only)
Definition at line 101 of file ex_gui_network.c.
References gui, HT_FOREACH, listbox_clients, n_gui_listbox_clear(), pool, and NETWORK_POOL::pool.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void usage | ( | void | ) |
Definition at line 246 of file ex_gui_network.c.
|
static |
| ALLEGRO_DISPLAY* display = NULL |
Definition at line 62 of file ex_gui_network.c.
|
static |
Definition at line 64 of file ex_gui_network.c.
|
static |
Definition at line 86 of file ex_gui_network.c.
Referenced by chat_log_add(), main(), main(), on_clear_click(), on_completion_select(), on_ghost_toggle(), on_grid_toggle(), on_height_toggle(), on_player_toggle(), on_proj_select(), on_search_change(), on_send_click(), on_smooth_toggle(), on_window_toggle_click(), on_windows_menu_open(), refresh_clients_list(), update_completion(), and update_definitions().
|
static |
|
static |
Definition at line 76 of file ex_gui_network.c.
|
static |
Definition at line 84 of file ex_gui_network.c.
Referenced by main(), and refresh_clients_list().
|
static |
Definition at line 77 of file ex_gui_network.c.
Referenced by chat_log_add(), and main().
|
static |
Definition at line 65 of file ex_gui_network.c.
Referenced by __attribute__(), _draw_bitmap_scaled(), add_particle(), add_particle_at(), add_particle_ex(), add_threaded_process(), draw_2d_panel(), draw_map(), main(), main(), n_daemonize_ex(), n_gui_add_slider(), n_gui_add_vslider(), n_gui_set_resize_mode(), n_kafka_load_config(), netw_init_wsa(), on_send_click(), poll_network_msgs(), scan_dir_ex(), and userlist_add_msg_to_ex().
|
static |
Definition at line 71 of file ex_gui_network.c.
Referenced by main(), and on_send_click().
|
static |
Definition at line 70 of file ex_gui_network.c.
Referenced by main().
|
static |
Definition at line 72 of file ex_gui_network.c.
Referenced by destroy_threaded_pool(), main(), netw_accept_pool_create(), netw_accept_pool_destroy(), netw_accept_pool_get_stats(), netw_accept_pool_start(), netw_accept_pool_stop(), netw_accept_pool_thread_func(), netw_accept_pool_wait(), netw_close(), on_send_click(), poll_network_msgs(), and refresh_clients_list().
|
static |
Definition at line 67 of file ex_gui_network.c.
Referenced by _proxy_tcp_connect(), main(), main(), and n_mock_server_start().
|
static |
|
static |
Definition at line 78 of file ex_gui_network.c.
Referenced by main(), and on_send_click().
|
static |
|
static |