-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
54 lines (41 loc) · 1.62 KB
/
server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef SERVER_H
#include <3ds.h>
#include "net.h"
typedef void (*sender_func_t)(net_t*, void*);
typedef struct {
net_t net; ///< Network structure.
sender_func_t sender_func; ///< Stored function that the server will run.
void* sender_info; ///< Information of the sender.
size_t server_info_size; ///< Size of sender info.
int count; ///< ???
int accept_skip; ///< Acceptable skip for each tick.
Handle server_timer; ///< svcHandle for a timer. Used for server sending items/second.
Thread server_thread; ///< Server thread to process the sender function.
LightEvent exit_thread; ///< Event to keep the server running.
aptHookCookie cookie; ///< Unused - Applet Cookie Hook.
} server_t;
/**
* @brief Constructor for a new server. Creates a newm non-detached thread.
* @param server pointer to a struct of server_t.
* @param func server functionality of type sender_func_t. e.g. found in servertypes, an input redirect.
* @param size size of function sender_func_t.
* @return 0 on sucess of thread creation.
*/
int server_ctor(server_t*, sender_func_t, size_t);
/**
* @brief Destructor for a server.
* @param server pointer to a struct of server_t.
* @return 0 on sucess of thread creation.
*/
int server_dtor(server_t*);
/**
* @brief Changes server send frequency.
* @param server pointer to a struct of server_t.
* @param num int to set frequency to per num seconds.
* @param dev int to set frequency of times per num.
* @param scr Console to print to.
* @return 0 on sucess of thread creation.
*/
void server_change_timer_freq(server_t*, int, int, PrintConsole*);
#define SERVER_H
#endif