6 Module N_USER
gullradriel edited this page 2026-10-29 20:54:40 +01:00

NETWORK USERS: server side network oriented user handling

Structures

Name
struct N_USERLIST
USER list.
struct N_USER
USER management cell.

Functions

Name
int userlist_user_send_waiting_msgs(N_USERLIST * ulist, int id)
send all waiting messages for a specific user
int userlist_user_add_waiting_msg(N_USERLIST * ulist, int id, N_STR * netmsg)
add a waiting message to a specific user's queue
int userlist_set_position_behavior(N_USERLIST * ulist, int id, int nb_rec_pos, int only_last_pos)
set position recording behavior for a user
int userlist_send_waiting_msgs(N_USERLIST * ulist)
send all waiting messages for all users in the list
N_USERLIST * userlist_new(int max)
allocate a new N_USERLIST with the given maximum number of users
int userlist_destroy(N_USERLIST ** ulist)
destroy a N_USERLIST and free all resources
int userlist_del_user(N_USERLIST * ulist, int id)
remove a user from the list by id
int userlist_add_user(N_USERLIST * ulist, NETWORK * netw)
add a user associated with a NETWORK connection to the list
int userlist_add_msg_to_ex(N_USERLIST * ulist, N_STR * msg, int mode, int id)
add a message to users selected by mode and id
int userlist_add_msg_to_all_except(N_USERLIST * ulist, N_STR * msg, int id)
add a message to all users except the one with the given id
int userlist_add_msg_to_all(N_USERLIST * ulist, N_STR * msg)
add a message to all users in the list
int userlist_add_msg_to(N_USERLIST * ulist, N_STR * msg, int id)
add a message to a specific user by id

Defines

Name
USERLIST_ONE
flag to target one user in the list
USERLIST_ALL_EXCEPT
flag to target all users in the list except one
USERLIST_ALL
flag to target all users in the list

Functions Documentation

function userlist_user_send_waiting_msgs

int userlist_user_send_waiting_msgs(
    N_USERLIST * ulist,
    int id
)

send all waiting messages for a specific user

Parameters:

  • ulist targeted N_USERLIST *list
  • id targeted user id

Return: TRUE or FALSE

send all waiting messages in user 'id' waiting list

send all waiting messages for a specific user

function userlist_user_add_waiting_msg

int userlist_user_add_waiting_msg(
    N_USERLIST * ulist,
    int id,
    N_STR * netmsg
)

add a waiting message to a specific user's queue

Parameters:

  • ulist targeted N_USERLIST *list
  • id targeted user id
  • netmsg network message to add

Return: TRUE or FALSE

add a network message to specified user 'id'

add a waiting message to a specific user's queue

function userlist_set_position_behavior

int userlist_set_position_behavior(
    N_USERLIST * ulist,
    int id,
    int nb_rec_pos,
    int only_last_pos
)

set position recording behavior for a user

Parameters:

  • 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 )

Return: TRUE or FALSE

set the position parameters for trajectory processing for user 'id'

set position recording behavior for a user

function userlist_send_waiting_msgs

int userlist_send_waiting_msgs(
    N_USERLIST * ulist
)

send all waiting messages for all users in the list

Parameters:

Return: TRUE or FALSE

send all waiting messages for each user of the list

send all waiting messages for all users in the list

function userlist_new

N_USERLIST * userlist_new(
    int max
)

allocate a new N_USERLIST with the given maximum number of users

Parameters:

  • max the maximum number of users in the list

Return: a new N_USERLIST *list or NULL

create a new N_USERLIST user list with 'max' users

allocate a new N_USERLIST with the given maximum number of users

function userlist_destroy

int userlist_destroy(
    N_USERLIST ** ulist
)

destroy a N_USERLIST and free all resources

Parameters:

Return: TRUE or FALSE

destroy and free a N_USERLIST *userlist

destroy a N_USERLIST and free all resources

function userlist_del_user

int userlist_del_user(
    N_USERLIST * ulist,
    int id
)

remove a user from the list by id

Parameters:

  • ulist targeted N_USERLIST *ulist
  • id id of the user to delete

Return: TRUE or FALSE

delete an user from the list

remove a user from the list by id

function userlist_add_user

int userlist_add_user(
    N_USERLIST * ulist,
    NETWORK * netw
)

add a user associated with a NETWORK connection to the list

Parameters:

  • ulist targeted N_USERLIST *ulist
  • netw associated NETWORK *network associated to the new use to create

Return: the new user id or -1 on error

add an user to the list

add a user associated with a NETWORK connection to the list

function userlist_add_msg_to_ex

int userlist_add_msg_to_ex(
    N_USERLIST * ulist,
    N_STR * msg,
    int mode,
    int id
)

add a message to users selected by mode and id

Parameters:

  • 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)

Return: TRUE or FALSE

add a N_STR *message to user list

add a message to users selected by mode and id

function userlist_add_msg_to_all_except

int userlist_add_msg_to_all_except(
    N_USERLIST * ulist,
    N_STR * msg,
    int id
)

add a message to all users except the one with the given id

Parameters:

  • ulist targeted N_USERLIST *ulist
  • id user id to ignore
  • msg network message to add

Return: TRUE or FALSE

add a N_STR *message to user list except user 'id' (USERLIST_ALL_EXCEPT)

add a message to all users except the one with the given id

function userlist_add_msg_to_all

int userlist_add_msg_to_all(
    N_USERLIST * ulist,
    N_STR * msg
)

add a message to all users in the list

Parameters:

  • ulist targeted N_USERLIST *ulist
  • msg network message to add

Return: TRUE or FALSE

add a N_STR *message to user list (USERLIST_ALL)

add a message to all users in the list

function userlist_add_msg_to

int userlist_add_msg_to(
    N_USERLIST * ulist,
    N_STR * msg,
    int id
)

add a message to a specific user by id

Parameters:

  • ulist targeted N_USERLIST *ulist
  • msg network message to add
  • id targeted user id

Return: TRUE or FALSE

add a N_STR *message to user list (USERLIST_ONE)

add a message to a specific user by id

Macros Documentation

define USERLIST_ONE

#define USERLIST_ONE 2

flag to target one user in the list

define USERLIST_ALL_EXCEPT

#define USERLIST_ALL_EXCEPT 1

flag to target all users in the list except one

define USERLIST_ALL

#define USERLIST_ALL 0

flag to target all users in the list