Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
struct | N_USER |
USER management cell. More... | |
struct | N_USERLIST |
USER list. More... | |
Macros | |
#define | USERLIST_ALL 0 |
flag to target all users in the list More... | |
#define | USERLIST_ALL_EXCEPT 1 |
flag to target all users in the list except one More... | |
#define | USERLIST_ONE 2 |
flag to target one user in the list More... | |
Functions | |
int | userlist_add_msg_to (N_USERLIST *ulist, N_STR *msg, int id) |
add a N_STR *message to user list (USERLIST_ONE) More... | |
int | userlist_add_msg_to_all (N_USERLIST *ulist, N_STR *msg) |
add a N_STR *message to user list (USERLIST_ALL) More... | |
int | userlist_add_msg_to_all_except (N_USERLIST *ulist, N_STR *msg, int id) |
add a N_STR *message to user list except user 'id' (USERLIST_ALL_EXCEPT) More... | |
int | userlist_add_msg_to_ex (N_USERLIST *ulist, N_STR *msg, int mode, int id) |
add a N_STR *message to user list More... | |
int | userlist_add_user (N_USERLIST *ulist, NETWORK *netw) |
add an user to the list More... | |
int | userlist_del_user (N_USERLIST *ulist, int id) |
delete an user from the list More... | |
int | userlist_destroy (N_USERLIST **ulist) |
destroy and free a N_USERLIST *userlist More... | |
N_USERLIST * | userlist_new (int max) |
create a new N_USERLIST user list with 'max' users More... | |
int | userlist_send_waiting_msgs (N_USERLIST *ulist) |
send all waiting messages ofr each user of the lsit More... | |
int | userlist_set_position_behavior (N_USERLIST *ulist, int id, int nb_rec_pos, int only_last_pos) |
set the position parameters for trajectory processing for user 'id' More... | |
int | userlist_user_add_waiting_msg (N_USERLIST *ulist, int id, N_STR *netmsg) |
add a newtork message to specified user 'id' More... | |
int | userlist_user_send_waiting_msgs (N_USERLIST *ulist, int id) |
send all waiting messages in user 'id' waiting list More... | |
struct N_USER |
Data Fields | ||
---|---|---|
int | id | Unique world ident. |
VECTOR3D * | last_positions | Last nb_rec_pos position messages, for a better dead reckoning / lag simulation. |
char | name[1024] | User Name. |
int | nb_rec_pos | Number of saved positions , default: 10. |
NETWORK * | netw | Associated NETWORK. |
LIST * | netw_waitlist | N_STR *messages waiting to be sent. |
int | only_last_pos | 1 => keep only_last_position in waitlist , 0 => send all the positions, default: 1 |
VECTOR3D | position | actual position |
int | state | State of the current user. |
struct N_USERLIST |
Data Fields | ||
---|---|---|
int | highter | Position of the highter user inside the list. |
N_USER * | list | Pointer to the allocated list of user. |
int | max | Maximum of user inside the list. |
pthread_rwlock_t | user_rwbolt | Mutex for thread safe user management. |
#define USERLIST_ALL_EXCEPT 1 |
int userlist_add_msg_to | ( | N_USERLIST * | ulist, |
N_STR * | msg, | ||
int | id | ||
) |
add a N_STR *message to user list (USERLIST_ONE)
ulist | targeted N_USERLIST *ulist |
msg | network message to add |
id | targeted user id |
Definition at line 240 of file n_user.c.
References userlist_add_msg_to_ex(), and USERLIST_ONE.
int userlist_add_msg_to_all | ( | N_USERLIST * | ulist, |
N_STR * | msg | ||
) |
add a N_STR *message to user list (USERLIST_ALL)
ulist | targeted N_USERLIST *ulist |
msg | network message to add |
Definition at line 252 of file n_user.c.
References userlist_add_msg_to_ex(), and USERLIST_ALL.
int userlist_add_msg_to_all_except | ( | N_USERLIST * | ulist, |
N_STR * | msg, | ||
int | id | ||
) |
add a N_STR *message to user list except user 'id' (USERLIST_ALL_EXCEPT)
ulist | targeted N_USERLIST *ulist |
id | user id to ignore |
msg | network message to add |
Definition at line 266 of file n_user.c.
References userlist_add_msg_to_ex(), and USERLIST_ALL_EXCEPT.
int userlist_add_msg_to_ex | ( | N_USERLIST * | ulist, |
N_STR * | msg, | ||
int | mode, | ||
int | id | ||
) |
add a N_STR *message to user list
ulist | targeted N_USERLIST *ulist |
msg | network message to add |
mode | one of USERLIST_ALL , USERLIST_ONE , USERLIST_ALL_EXCEPT |
id | targeted user id to use (USERLIST_ONE) or to ignore (USERLIST_ALL_EXCEPT) |
Definition at line 191 of file n_user.c.
References __n_assert, netw_add_msg(), nstrdup(), read_lock, unlock, USERLIST_ALL, USERLIST_ALL_EXCEPT, and USERLIST_ONE.
Referenced by userlist_add_msg_to(), userlist_add_msg_to_all(), and userlist_add_msg_to_all_except().
int userlist_add_user | ( | N_USERLIST * | ulist, |
NETWORK * | netw | ||
) |
add an user to the list
ulist | targeted N_USERLIST *ulist |
netw | associated NETWORK *network associated to the new use to create |
Definition at line 101 of file n_user.c.
References __n_assert, unlock, and write_lock.
int userlist_del_user | ( | N_USERLIST * | ulist, |
int | id | ||
) |
delete an user from the list
ulist | targeted N_USERLIST *ulist |
id | id of the user to delete |
Definition at line 134 of file n_user.c.
References __n_assert, list_empty(), LOG_ERR, n_log, Realloc, unlock, and write_lock.
int userlist_destroy | ( | N_USERLIST ** | ulist | ) |
destroy and free a N_USERLIST *userlist
ulist | targeted N_USERLIST *list to destroy |
Definition at line 278 of file n_user.c.
References __n_assert, Free, list_destroy(), unlock, and write_lock.
N_USERLIST * userlist_new | ( | int | max | ) |
create a new N_USERLIST user list with 'max' users
max | the maximum number of users in the list |
Definition at line 16 of file n_user.c.
References __n_assert, Free, init_lock, Malloc, and new_generic_list().
int userlist_send_waiting_msgs | ( | N_USERLIST * | ulist | ) |
send all waiting messages ofr each user of the lsit
ulist | targeted N_USERLIST *list |
Definition at line 362 of file n_user.c.
References __n_assert, list_empty(), list_foreach, netw_add_msg(), read_lock, and unlock.
int userlist_set_position_behavior | ( | N_USERLIST * | ulist, |
int | id, | ||
int | nb_rec_pos, | ||
int | only_last_pos | ||
) |
set the position parameters for trajectory processing for user 'id'
ulist | targeted N_USERLIST *ulist |
id | id of the user |
nb_rec_pos | number of positions updates kept in list |
only_last_pos | flag if we're only keeping the last position ( if set nb_rec_pos is ignored ) |
Definition at line 57 of file n_user.c.
References __n_assert, LOG_ERR, n_log, read_lock, Realloc, unlock, and write_lock.
int userlist_user_add_waiting_msg | ( | N_USERLIST * | ulist, |
int | id, | ||
N_STR * | netmsg | ||
) |
add a newtork message to specified user 'id'
ulist | targeted N_USERLIST *list |
id | targeted user id |
netmsg | network message to add |
Definition at line 306 of file n_user.c.
References __n_assert, list_push(), read_lock, and unlock.
int userlist_user_send_waiting_msgs | ( | N_USERLIST * | ulist, |
int | id | ||
) |
send all waiting messages in user 'id' waiting list
ulist | targeted N_USERLIST *list |
id | targeted user id |
Definition at line 334 of file n_user.c.
References __n_assert, list_empty(), list_foreach, netw_add_msg(), read_lock, and unlock.