Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
Typedefs | Functions
tchatator413.h File Reference

Facade interface. More...

#include "action.h"
#include "cfg.h"
#include "db.h"
#include "server.h"
#include <json-c.h>

Go to the source code of this file.

Typedefs

typedef void(* fn_on_action_t) (const action_t *action, void *ctx)
 An event handler for when the server has parsed an action.
 
typedef void(* fn_on_response_t) (const response_t *response, void *ctx)
 An event handler for when the server has interpeted an action.
 

Functions

json_object * tchatator413_interpret (json_object *input, cfg_t *cfg, db_t *db, server_t *server, fn_on_action_t on_action, fn_on_response_t on_response, void *on_ctx)
 Interpret a request.
 
int tchatator413_run_interactive (cfg_t *cfg, db_t *db, server_t *server, int argc, char **argv)
 Run the server in interactive mode.
 
int tchatator413_run_socket (cfg_t *cfg, db_t *db, server_t *server)
 Run the server in socket mode.
 

Detailed Description

Facade interface.

Author
Raphaƫl
Date
1/02/2025

Definition in file tchatator413.h.

Typedef Documentation

◆ fn_on_action_t

typedef void(* fn_on_action_t) (const action_t *action, void *ctx)

An event handler for when the server has parsed an action.

Definition at line 16 of file tchatator413.h.

◆ fn_on_response_t

typedef void(* fn_on_response_t) (const response_t *response, void *ctx)

An event handler for when the server has interpeted an action.

Definition at line 18 of file tchatator413.h.

Function Documentation

◆ tchatator413_interpret()

json_object * tchatator413_interpret ( json_object *  input,
cfg_t cfg,
db_t db,
server_t server,
fn_on_action_t  on_action,
fn_on_response_t  on_response,
void *  on_ctx 
)

Interpret a request.

Parameters
inputThe request JSON object.
cfgThe configuration.
dbThe database.
serverThe server's state.
on_actionEvent handler to call when the action is parsed. Cab be NULL.
on_responseEvent handler to call when the action is interpreted. Cab be NULL.
on_ctxThe contect to pass to the previous event handlers.
Returns
The JSON response object to the request.

◆ tchatator413_run_interactive()

int tchatator413_run_interactive ( cfg_t cfg,
db_t db,
server_t server,
int  argc,
char **  argv 
)

Run the server in interactive mode.

Parameters
cfgThe configuration.
dbThe database.
serverThe server's state.
argcArgument count.
argvArgument vector.
Returns
The exit code of the server.

◆ tchatator413_run_socket()

int tchatator413_run_socket ( cfg_t cfg,
db_t db,
server_t server 
)

Run the server in socket mode.

Parameters
cfgThe configuration.
dbThe database.
serverThe server's state.
Returns
The exit code of the server.