Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
server.h
Go to the documentation of this file.
1
5
6#ifndef SERVER_STATE_H
7#define SERVER_STATE_H
8
9#include "types.h"
10#include <stdbool.h>
11#include <time.h>
12
13typedef struct {
21
23typedef struct server server_t;
24
29server_t *server_create(api_key_t admin_api_key, char const *admin_password);
30
34
41
48
54bool server_check_admin_password(server_t *server, char const *password);
55
61bool server_logout(server_t *server, token_t token);
62
69
70#endif // SERVER_STATE_H
bool server_logout(server_t *server, token_t token)
Deletes a session, logging out an user.
void server_destroy(server_t *server)
Destroys the specified server instance.
token_t server_login(server_t *server, serial_t user_id)
Creates a new session, logging in an user.
bool server_is_admin_api_key(server_t *server, api_key_t api_key)
Checks if an API key is the admin API key.
bool server_check_admin_password(server_t *server, char const *password)
Check a password against the admin password.
server_t * server_create(api_key_t admin_api_key, char const *admin_password)
Creates a new server instance.
struct server server_t
Opaque type handle representing a server instance.
Definition server.h:23
serial_t server_verify_token(server_t *server, token_t token)
Verifies a token, returning its owning user ID.
int n_requests_h
Number of requests performed since an hour.
Definition server.h:17
int n_requests_m
Number of requests performed since a minute.
Definition server.h:19
time_t last_request_at
Timestamp of the last request.
Definition server.h:15
Version 4 UUID.
Definition uuid.h:15
General types - Standalone header.
int32_t serial_t
A PosrgreSQL SERIAL primary key value starting at 1. (1..2^31-1)
Definition types.h:22
int64_t token_t
A session token.
Definition types.h:18