![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Network messages function. More...
#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include "nilorea/n_network.h"#include "nilorea/n_network_msg.h"
Include dependency graph for n_network_msg.c:Go to the source code of this file.
Functions | |
| int | add_bytes_to_msg (NETW_MSG *msg, const void *bytes, size_t len) |
| Add a binary blob to the message (clean alias for a raw N_STR payload, distinguishes binary data from character strings at call sites). | |
| int | add_int_to_msg (NETW_MSG *msg, int value) |
| Add an int to the int list int the message. | |
| int | add_nb_to_msg (NETW_MSG *msg, double value) |
| Add an float to the message. | |
| int | add_nstrdup_to_msg (NETW_MSG *msg, N_STR *str) |
| Add a copy of str to the string list in the message. | |
| int | add_nstrptr_to_msg (NETW_MSG *msg, N_STR *str) |
| Add a string to the string list in the message. | |
| int | add_strdup_to_msg (NETW_MSG *msg, const char *str) |
| Add a copy of char *str to the string list in the message. | |
| int | create_msg (NETW_MSG **msg) |
| Create a NETW_MSG *object. | |
| int | delete_msg (NETW_MSG **msg) |
| Delete a NETW_MSG *object. | |
| double | double_swap (double value) |
| Swap bytes endiannes for a double. | |
| int | empty_msg (NETW_MSG **msg) |
| Empty a NETW_MSG *object. | |
| int | get_bytes_from_msg (NETW_MSG *msg, void **out_bytes, size_t *out_len) |
| Get a binary blob from the message (counterpart of add_bytes_to_msg). | |
| int | get_int_from_msg (NETW_MSG *msg, int *value) |
| Get an int from a message int list. | |
| int | get_nb_from_msg (NETW_MSG *msg, double *value) |
| Get a number from a message number list. | |
| int | get_nstr_from_msg (NETW_MSG *msg, N_STR **value) |
| Get a string from a message string list. | |
| int | get_str_from_msg (NETW_MSG *msg, char **value) |
| Get a string from a message string list. | |
| double | htond (double value) |
| If needed swap bytes for a double. | |
| NETW_MSG * | make_msg_from_str (N_STR *str) |
| Make a single message of the string. | |
| N_STR * | make_str_from_msg (NETW_MSG *msg) |
| Make a single string of the message. | |
| N_STR * | netmsg_make_ident (int type, int id, N_STR *name, N_STR *passwd) |
| Add a formatted NETWMSG_IDENT message to the specified network. | |
| N_STR * | netmsg_make_ping (int type, int id_from, int id_to, int time) |
| Make a ping message to send to a network. | |
| N_STR * | netmsg_make_position_msg (int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp) |
| make a network NETMSG_POSITION message with given parameters | |
| N_STR * | netmsg_make_quit_msg (void) |
| make a generic network NETMSG_QUIT message | |
| N_STR * | netmsg_make_string_msg (int id_from, int id_to, N_STR *name, N_STR *chan, N_STR *txt, int color) |
| make a network NETMSG_STRING message with given parameters | |
| void | netw_bytes_stats_get (long long *sent, long long *recv) |
Read process-wide network byte counters, sum of N_STR.written across every netw_add_msg / netw_get_msg call. | |
| int | netw_get_ident (N_STR *msg, int *type, int *ident, N_STR **name, N_STR **passwd) |
| Retrieves identification from netwmsg. | |
| int | netw_get_ping (N_STR *msg, int *type, int *from, int *to, int *time) |
| Retrieves a ping travel elapsed time. | |
| int | netw_get_position (N_STR *msg, int *id, double *X, double *Y, double *vx, double *vy, double *acc_x, double *acc_y, int *time_stamp) |
| Retrieves position from netwmsg. | |
| int | netw_get_quit (N_STR *msg) |
| get a formatted NETWMSG_QUIT message from the specified network | |
| int | netw_get_string (N_STR *msg, int *id, N_STR **name, N_STR **chan, N_STR **txt, int *color) |
| Retrieves string from netwmsg. | |
| int | netw_msg_get_type (N_STR *msg) |
| Get the type of message without killing the first number. Use with netw_get_XXX. | |
| void | netw_msg_stats_get (long long *created, long long *deleted) |
| Read lifecycle counters. | |
| double | ntohd (double value) |
| If needed swap bytes for a double. | |
Variables | |
| long long | g_netw_bytes_recv |
| long long | g_netw_bytes_sent |
| Add a message to send in aimed NETWORK. | |
| static long long | g_netw_msg_created = 0 |
| static long long | g_netw_msg_deleted = 0 |
|
extern |
Definition at line 3567 of file n_network.c.
Referenced by netw_bytes_stats_get(), and netw_get_msg().
|
extern |
Add a message to send in aimed NETWORK.
| netw | NETWORK where add the message |
| msg | the message to add |
Definition at line 3566 of file n_network.c.
Referenced by netw_add_msg(), and netw_bytes_stats_get().
|
static |
Definition at line 35 of file n_network_msg.c.
Referenced by create_msg(), and netw_msg_stats_get().
|
static |
Definition at line 36 of file n_network_msg.c.
Referenced by delete_msg(), and netw_msg_stats_get().