Nilorea Library
C utilities for networking, threading, graphics
All Data Structures Files Functions Variables Typedefs Enumerations Macros Modules Pages
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#endif
15
16#include "nilorea/n_common.h"
17#include "nilorea/n_log.h"
18#include "nilorea/n_str.h"
19#include "nilorea/n_network.h"
20#include "nilorea/n_3d.h"
21
28#define USERLIST_ALL 0
30#define USERLIST_ALL_EXCEPT 1
32#define USERLIST_ONE 2
33
60
62typedef struct N_USERLIST {
65
67 int max,
70
72 pthread_rwlock_t user_rwbolt;
73
75
76N_USERLIST* userlist_new(int max);
77int userlist_set_position_behavior(N_USERLIST* ulist, int id, int nb_rec_pos, int only_last_pos);
78int userlist_add_user(N_USERLIST* ulist, NETWORK* netw);
79int userlist_del_user(N_USERLIST* ulist, int id);
80int userlist_add_msg_to_ex(N_USERLIST* ulist, N_STR* msg, int mode, int id);
81int userlist_add_msg_to(N_USERLIST* ulist, N_STR* msg, int id);
83int userlist_add_msg_to_all_except(N_USERLIST* ulist, N_STR* msg, int id);
84int userlist_destroy(N_USERLIST** ulist);
85int userlist_user_add_waiting_msg(N_USERLIST* ulist, int id, N_STR* netmsg);
88
93#ifdef __cplusplus
94}
95#endif
96
97#endif // header guard
Structure of a generic LIST container.
Definition n_list.h:39
A box including a string and his lenght.
Definition n_str.h:39
char name[1024]
User Name.
Definition n_user.h:37
VECTOR3D * last_positions
Last nb_rec_pos position messages, for a better dead reckoning / lag simulation.
Definition n_user.h:52
int only_last_pos
1 => keep only_last_position in waitlist , 0 => send all the positions, default: 1
Definition n_user.h:47
int max
Maximum of user inside the list.
Definition n_user.h:67
LIST * netw_waitlist
N_STR *messages waiting to be sent.
Definition n_user.h:57
pthread_rwlock_t user_rwbolt
Mutex for thread safe user management.
Definition n_user.h:72
int state
State of the current user.
Definition n_user.h:43
VECTOR3D position
actual position
Definition n_user.h:54
NETWORK * netw
Associated NETWORK.
Definition n_user.h:40
int highter
Position of the highter user inside the list.
Definition n_user.h:69
int id
Unique world ident.
Definition n_user.h:49
int nb_rec_pos
Number of saved positions , default: 10.
Definition n_user.h:45
N_USER * list
Pointer to the allocated list of user.
Definition n_user.h:64
int userlist_del_user(N_USERLIST *ulist, int id)
delete an user from the list
Definition n_user.c:114
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:205
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:162
int userlist_user_send_waiting_msgs(N_USERLIST *ulist, int id)
send all waiting messages in user 'id' waiting list
Definition n_user.c:282
N_USERLIST * userlist_new(int max)
create a new N_USERLIST user list with 'max' users
Definition n_user.c:14
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:215
int userlist_send_waiting_msgs(N_USERLIST *ulist)
send all waiting messages ofr each user of the lsit
Definition n_user.c:305
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:51
int userlist_add_user(N_USERLIST *ulist, NETWORK *netw)
add an user to the list
Definition n_user.c:87
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:226
int userlist_destroy(N_USERLIST **ulist)
destroy and free a N_USERLIST *userlist
Definition n_user.c:235
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:259
USER management cell.
Definition n_user.h:35
USER list.
Definition n_user.h:62
Structure of a NETWORK.
Definition n_network.h:236
double VECTOR3D[3]
struct of a point
Definition n_3d.h:39
Simple 3D movement simulation.
Common headers and low-level functions & define.
Generic log system.
Network Engine.
N_STR and string function declaration.