Nilorea Library
C utilities for networking, threading, graphics
n_user.h
Go to the documentation of this file.
1
8#ifndef N_USER_MANAGEMENT
9
10#define N_USER_MANAGEMENT
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif
16
17#include "nilorea/n_common.h"
18#include "nilorea/n_log.h"
19#include "nilorea/n_str.h"
20#include "nilorea/n_network.h"
21#include "nilorea/n_3d.h"
22
29#define USERLIST_ALL 0
31#define USERLIST_ALL_EXCEPT 1
33#define USERLIST_ONE 2
34
36typedef struct N_USER
37{
39 char name[ 1024 ];
40
43
45 int state,
52
57
60
61} N_USER ;
62
63
64
66typedef struct N_USERLIST
67{
70
72 int max,
75
77 pthread_rwlock_t user_rwbolt;
78
79} N_USERLIST ;
80
81
82
83N_USERLIST *userlist_new( int max );
84int userlist_set_position_behavior( N_USERLIST *ulist, int id, int nb_rec_pos, int only_last_pos );
85int userlist_add_user( N_USERLIST *ulist, NETWORK *netw );
86int userlist_del_user( N_USERLIST *ulist, int id );
87int userlist_add_msg_to_ex( N_USERLIST *ulist, N_STR *msg, int mode, int id );
88int userlist_add_msg_to( N_USERLIST *ulist, N_STR *msg, int id );
89int userlist_add_msg_to_all( N_USERLIST *ulist, N_STR *msg );
90int userlist_add_msg_to_all_except( N_USERLIST *ulist, N_STR *msg, int id );
91int userlist_destroy( N_USERLIST **ulist );
92int userlist_user_add_waiting_msg( N_USERLIST *ulist, int id, N_STR *netmsg );
95
100#ifdef __cplusplus
101}
102#endif
103
104#endif // header guard
105
Structure of a generic LIST container.
Definition: n_list.h:45
A box including a string and his lenght.
Definition: n_str.h:173
char name[1024]
User Name.
Definition: n_user.h:39
VECTOR3D * last_positions
Last nb_rec_pos position messages, for a better dead reckoning / lag simulation.
Definition: n_user.h:54
int only_last_pos
1 => keep only_last_position in waitlist , 0 => send all the positions, default: 1
Definition: n_user.h:49
int max
Maximum of user inside the list.
Definition: n_user.h:72
LIST * netw_waitlist
N_STR *messages waiting to be sent.
Definition: n_user.h:59
pthread_rwlock_t user_rwbolt
Mutex for thread safe user management.
Definition: n_user.h:77
int state
State of the current user.
Definition: n_user.h:45
VECTOR3D position
actual position
Definition: n_user.h:56
NETWORK * netw
Associated NETWORK.
Definition: n_user.h:42
int highter
Position of the highter user inside the list.
Definition: n_user.h:74
int id
Unique world ident.
Definition: n_user.h:51
int nb_rec_pos
Number of saved positions , default: 10.
Definition: n_user.h:47
N_USER * list
Pointer to the allocated list of user.
Definition: n_user.h:69
int userlist_del_user(N_USERLIST *ulist, int id)
delete an user from the list
Definition: n_user.c:134
int userlist_add_msg_to(N_USERLIST *ulist, N_STR *msg, int id)
add a N_STR *message to user list (USERLIST_ONE)
Definition: n_user.c:240
int userlist_add_msg_to_ex(N_USERLIST *ulist, N_STR *msg, int mode, int id)
add a N_STR *message to user list
Definition: n_user.c:191
int userlist_user_send_waiting_msgs(N_USERLIST *ulist, int id)
send all waiting messages in user 'id' waiting list
Definition: n_user.c:334
N_USERLIST * userlist_new(int max)
create a new N_USERLIST user list with 'max' users
Definition: n_user.c:16
int userlist_add_msg_to_all(N_USERLIST *ulist, N_STR *msg)
add a N_STR *message to user list (USERLIST_ALL)
Definition: n_user.c:252
int userlist_send_waiting_msgs(N_USERLIST *ulist)
send all waiting messages ofr each user of the lsit
Definition: n_user.c:362
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'
Definition: n_user.c:57
int userlist_add_user(N_USERLIST *ulist, NETWORK *netw)
add an user to the list
Definition: n_user.c:101
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)
Definition: n_user.c:266
int userlist_destroy(N_USERLIST **ulist)
destroy and free a N_USERLIST *userlist
Definition: n_user.c:278
int userlist_user_add_waiting_msg(N_USERLIST *ulist, int id, N_STR *netmsg)
add a newtork message to specified user 'id'
Definition: n_user.c:306
USER management cell.
Definition: n_user.h:37
USER list.
Definition: n_user.h:67
Structure of a NETWORK.
Definition: n_network.h:252
double VECTOR3D[3]
struct of a point
Definition: n_3d.h:39
Simple 3D movement simulation.
Common headers and low-level hugly functions & define.
Generic log system.
Network Engine.
N_STR and string function declaration.