Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_user.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
27#ifndef N_USER_MANAGEMENT
28
29#define N_USER_MANAGEMENT
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include "nilorea/n_common.h"
36#include "nilorea/n_log.h"
37#include "nilorea/n_str.h"
38#include "nilorea/n_network.h"
39#include "nilorea/n_3d.h"
40
47#define USERLIST_ALL 0
49#define USERLIST_ALL_EXCEPT 1
51#define USERLIST_ONE 2
52
79
81typedef struct N_USERLIST {
84
86 int max,
89
91 pthread_rwlock_t user_rwbolt;
92
94
96N_USERLIST* userlist_new(int max);
98int userlist_set_position_behavior(N_USERLIST* ulist, int id, int nb_rec_pos, int only_last_pos);
102int userlist_del_user(N_USERLIST* ulist, int id);
104int userlist_add_msg_to_ex(N_USERLIST* ulist, N_STR* msg, int mode, int id);
106int userlist_add_msg_to(N_USERLIST* ulist, N_STR* msg, int id);
110int userlist_add_msg_to_all_except(N_USERLIST* ulist, N_STR* msg, int id);
112int userlist_destroy(N_USERLIST** ulist);
114int userlist_user_add_waiting_msg(N_USERLIST* ulist, int id, N_STR* netmsg);
119
124#ifdef __cplusplus
125}
126#endif
127
128#endif // header guard
static int mode
NETWORK * netw
Network for server mode, accepting incomming.
Definition ex_network.c:39
Structure of a generic LIST container.
Definition n_list.h:59
A box including a string and his lenght.
Definition n_str.h:61
char name[1024]
User Name.
Definition n_user.h:56
VECTOR3D * last_positions
Last nb_rec_pos position messages, for a better dead reckoning / lag simulation.
Definition n_user.h:71
int only_last_pos
1 => keep only_last_position in waitlist , 0 => send all the positions, default: 1
Definition n_user.h:66
int max
Maximum of user inside the list.
Definition n_user.h:86
LIST * netw_waitlist
N_STR *messages waiting to be sent.
Definition n_user.h:76
pthread_rwlock_t user_rwbolt
Mutex for thread safe user management.
Definition n_user.h:91
int state
State of the current user.
Definition n_user.h:62
VECTOR3D position
actual position
Definition n_user.h:73
NETWORK * netw
Associated NETWORK.
Definition n_user.h:59
int highter
Position of the highter user inside the list.
Definition n_user.h:88
int id
Unique world ident.
Definition n_user.h:68
int nb_rec_pos
Number of saved positions , default: 10.
Definition n_user.h:64
N_USER * list
Pointer to the allocated list of user.
Definition n_user.h:83
int userlist_del_user(N_USERLIST *ulist, int id)
remove a user from the list by id
Definition n_user.c:145
int userlist_add_msg_to(N_USERLIST *ulist, N_STR *msg, int id)
add a message to a specific user by id
Definition n_user.c:236
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
Definition n_user.c:193
int userlist_user_send_waiting_msgs(N_USERLIST *ulist, int id)
send all waiting messages for a specific user
Definition n_user.c:313
N_USERLIST * userlist_new(int max)
allocate a new N_USERLIST with the given maximum number of users
Definition n_user.c:34
int userlist_add_msg_to_all(N_USERLIST *ulist, N_STR *msg)
add a message to all users in the list
Definition n_user.c:246
int userlist_send_waiting_msgs(N_USERLIST *ulist)
send all waiting messages for all users in the list
Definition n_user.c:336
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
Definition n_user.c:71
int userlist_add_user(N_USERLIST *ulist, NETWORK *netw)
add a user associated with a NETWORK connection to the list
Definition n_user.c:118
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
Definition n_user.c:257
int userlist_destroy(N_USERLIST **ulist)
destroy a N_USERLIST and free all resources
Definition n_user.c:266
int userlist_user_add_waiting_msg(N_USERLIST *ulist, int id, N_STR *netmsg)
add a waiting message to a specific user's queue
Definition n_user.c:290
USER management cell.
Definition n_user.h:54
USER list.
Definition n_user.h:81
Structure of a NETWORK.
Definition n_network.h:309
double VECTOR3D[3]
struct of a point
Definition n_3d.h:59
Simple 3D movement simulation.
Common headers and low-level functions & define.
Generic log system.
Network Engine.
N_STR and string function declaration.