Data Fields
vtm_nm_stream_srv_cbs Struct Reference

Data Fields

void(* server_ready )(vtm_nm_stream_srv *srv, struct vtm_nm_stream_srv_opts *opts)
 
void(* worker_init )(vtm_nm_stream_srv *srv, vtm_dataset *wd)
 
void(* worker_end )(vtm_nm_stream_srv *srv, vtm_dataset *wd)
 
void(* client_connect )(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con)
 
void(* client_disconnect )(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con)
 
void(* client_msg )(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con, vtm_dataset *msg)
 

Detailed Description

Holds the user defined callbacks for a NM stream server.

When a specific callback is not needed, then is MUST be set to NULL.

Unless otherwise stated each callback function is called from a worker-thread. When the server runs in single-threaded mode, the functions are called from the main thread that started the server.

Field Documentation

void(* vtm_nm_stream_srv_cbs::server_ready)(vtm_nm_stream_srv *srv, struct vtm_nm_stream_srv_opts *opts)

This function is called when the socket of the server was successfully created and is ready to accept incoming connections.

The function is called in the same thread that called vtm_nm_stream_srv_run()

Parameters
srvthe server which is ready
optsthe options of the server
void(* vtm_nm_stream_srv_cbs::worker_init)(vtm_nm_stream_srv *srv, vtm_dataset *wd)

This function is is called during startup phase of the server for each worker thread.

Parameters
srvthe server
wdan empty dataset set. The same dataset is later delivered to this thread in the other callbacks. You can store things here that may be used during processing of client messages, for example a database connection.
void(* vtm_nm_stream_srv_cbs::worker_end)(vtm_nm_stream_srv *srv, vtm_dataset *wd)

This function is called during shutdown phase of the server for each worker thread.

Parameters
srvthe server
wdthe working dataset
void(* vtm_nm_stream_srv_cbs::client_connect)(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con)

A new client has connected to the server.

Parameters
srvthe server
wdthe working dataset
conthe connection associated with the new client
void(* vtm_nm_stream_srv_cbs::client_disconnect)(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con)

A client connection was closed.

Parameters
srvthe server
wdthe working dataset
conthe connection that was closed
void(* vtm_nm_stream_srv_cbs::client_msg)(vtm_nm_stream_srv *srv, vtm_dataset *wd, vtm_nm_stream_con *con, vtm_dataset *msg)

A new message was received.

Parameters
srvthe server
wdthe working dataset
conthe connection that sent the msg
msgthe received message