![]() |
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 | |
#define | USERLIST_ALL_EXCEPT 1 |
flag to target all users in the list except one | |
#define | USERLIST_ONE 2 |
flag to target one user in the list | |
Functions | |
int | userlist_add_msg_to (N_USERLIST *ulist, N_STR *msg, int id) |
add a N_STR *message to user list (USERLIST_ONE) | |
int | userlist_add_msg_to_all (N_USERLIST *ulist, N_STR *msg) |
add a N_STR *message to user list (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) | |
int | userlist_add_msg_to_ex (N_USERLIST *ulist, N_STR *msg, int mode, int id) |
add a N_STR *message to user list | |
int | userlist_add_user (N_USERLIST *ulist, NETWORK *netw) |
add an user to the list | |
int | userlist_del_user (N_USERLIST *ulist, int id) |
delete an user from the list | |
int | userlist_destroy (N_USERLIST **ulist) |
destroy and free a N_USERLIST *userlist | |
N_USERLIST * | userlist_new (int max) |
create a new N_USERLIST user list with 'max' users | |
int | userlist_send_waiting_msgs (N_USERLIST *ulist) |
send all waiting messages ofr each user of the lsit | |
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' | |
int | userlist_user_add_waiting_msg (N_USERLIST *ulist, int id, N_STR *netmsg) |
add a newtork message to specified user 'id' | |
int | userlist_user_send_waiting_msgs (N_USERLIST *ulist, int id) |
send all waiting messages in user 'id' waiting list | |
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 205 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 215 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 226 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 162 of file n_user.c.
References __n_assert, N_USERLIST::highter, N_USERLIST::list, netw, netw_add_msg(), nstrdup(), read_lock, state, unlock, N_USERLIST::user_rwbolt, 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 87 of file n_user.c.
References __n_assert, N_USERLIST::highter, N_USERLIST::list, netw, state, unlock, N_USERLIST::user_rwbolt, 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 114 of file n_user.c.
References __n_assert, N_USERLIST::highter, id, last_positions, N_USERLIST::list, list_empty(), LOG_ERR, N_USERLIST::max, n_log, name, nb_rec_pos, netw, netw_waitlist, only_last_pos, position, Realloc, state, unlock, N_USERLIST::user_rwbolt, 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 235 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 14 of file n_user.c.
References __n_assert, Free, N_USERLIST::highter, id, init_lock, last_positions, N_USERLIST::list, Malloc, N_USERLIST::max, MAX_LIST_ITEMS, name, nb_rec_pos, netw, netw_waitlist, only_last_pos, position, state, and N_USERLIST::user_rwbolt.
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 305 of file n_user.c.
References __n_assert, N_USERLIST::highter, N_USERLIST::list, list_empty(), list_foreach, netw, netw_add_msg(), netw_waitlist, read_lock, state, unlock, and N_USERLIST::user_rwbolt.
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 51 of file n_user.c.
References __n_assert, last_positions, N_USERLIST::list, LOG_ERR, n_log, nb_rec_pos, only_last_pos, read_lock, Realloc, state, unlock, N_USERLIST::user_rwbolt, 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 259 of file n_user.c.
References __n_assert, N_USERLIST::list, list_push(), netw_waitlist, read_lock, state, unlock, and N_USERLIST::user_rwbolt.
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 282 of file n_user.c.
References __n_assert, N_USERLIST::list, list_empty(), list_foreach, netw, netw_add_msg(), netw_waitlist, read_lock, state, unlock, and N_USERLIST::user_rwbolt.