nngd.nngd

Undocumented in source.

Members

Functions

nng_find_mime_type
string nng_find_mime_type(string fname, string[string] custom_map)

{nng_find_mime_type} Find mime map in the static and custom map tables

nng_pool_stateful
void nng_pool_stateful(void* p)

NNGPool state machine callback switching between SEND-RECV-WAIT states

toString
string toString(nng_sockaddr a)

Render nng_sockaddr to human readableform

webrouter
void webrouter(nng_aio* aio)

Internal callback to extract WebData from AIO and fingd proper handler

webstatichandler
void webstatichandler(nng_aio* aio)

Internal callback for static routes

Structs

NNGAio
struct NNGAio

{NNGAio} Async IO poller for many purposes. Contains the NNGMessage payload and optional context pointer. General usage - inter-thread communication. Properties: - pointer: to read the internal nng_aio pointer - pointer: to set the nng_aio pointer to external one - context: to read the stored context - count: number of bytes transfwred by the AIO operation - result: result of the AIO operation - zero or error code - timeout: to set teh poll timeout Methods: - constructor -- callback pointer: function or delegate void (void*) -- argument pointer: to be sent to callback -- context pointer: to store and retrieve - realloc: same agruments as constructor - to reuse and rearm aio - begin: begin postponed AIO aopertion - wait: block until AIO success or error or timeout - sleep: performs an asynchronous "sleep", causing the callback for aio to be executed after delay - abort: abort immediately, return error as result but call callback - cancel: like abort with predefined error NNG_ECANCELED - stop: like cancel but prevent callback from calling, except it is already running - get_msg: extract NNGMessage passed to the AIO - set_msg: push NNGMessage to aio before start operation - clear_msg: clear stored NNGMessage TODO: implement [get/set] input/output/iov

NNGMessage
struct NNGMessage

{NNGMessage} Dynamically constructed structure to serialize everything for NNG transport Contains header and body buffers which may be composed and decomposed separately Properties: - pointer: to access internal nng_msg pointer - bodyptr: toaccess the body pointer - headerptr: to access the header pointer - lengthL message length - header_length: header length Methods: - constructor: accept the buffer size to allocate initially - body_append/body_prepend (template): add part to the body end or begin - body_chop (template): remove and return part from the end of body - body_trim (template): remove and return part from the beginnning of body - header_append/header_prepend (template): add part to the header end or begin - header_chop (template): remove and return part from the end of header - header_trim (template): remove and return part from the beginnning of header

NNGPool
struct NNGPool

{NNGPool} Connection pool to implement multithreaded REQ/REP socket server Pool creates the set of NNGPoolWorker instances containing shared state machines and associate its nng context with socket Methods: - constructor -- socket pointer: shoud be nng_socket_type.NNG_SOCKET_REP but may be extended -- callback: receiving message and context - void function(NNGMessage*, void*); -- number of workers -- void* context to pass into callback -- file to forward log messages to - init: initialize workers state machines - shutdown

NNGPoolWorker
struct NNGPoolWorker

{NNGPoolWorker} Worker implements the state machine to process requests coming from the NNGPool instance through (pool socket -> nng_ctx -> worker state) Not to direct use May be declared as private or module scope

NNGSocket
struct NNGSocket

{NNGSocket} The main socket wrapper Socket may be created of one of the above described types Most types has dialer-listener pairs: PUSH/PULL, REQ/REP, PUB/SUB... Methods: - constructor -- type -- raw flag (see NNG doc) - close: close socket, wait for status changes

NNGTLS
struct NNGTLS

{MMGTLS} NNG TLS config implementation - create it in server or client mode - set CA certifivate if needed (from file or string) - set chain certificate if needed (from file or string) - set auth mode (required, optional or none) - for auth mode set own certificate and key (from file or string) - assign the filled config to the dealer or listener object - start dealer or listener

NNGURL
struct NNGURL

{NNGURL} Wrapper over nng_url_parse function to represent the URL parts

WebApp
struct WebApp

{WebApp} Web server application based on nng_http_* inspired by Flask Methods - constructor, parameters: -- server name to identify instance -- server url (http or https) -- json config or WebAppConfig object, attributes

WebClient
struct WebClient
Undocumented in source.
WebData
struct WebData

{WebData} Object to store all HTTP request-reply data and pass between handlers and server Attributes: - route: route name in the server route table (R) - rawuri: full URL string (R) - uri: URL hostname (R) - method: GET, POST, etc (R) - type: content-type (R/W) - length: size of request data (R) - path: array with URL path splitted by slashes (R) - param: srtingstring http param list like ?key=value (R) - headers: srtingstring http headers (R/W) - rawdtata: ubyte[] POST data of binary types (R/W) - json: POST data of json type (R/W) - text: POST data of text-like types (R/W) - status: enum http_status (W)

WebSocket
struct WebSocket

{WebSocket} WebSocket connection accepted by the {WebSocketApp} server Not for manual construction Passed to the on_connect and om_message callbacks Methods: send(ubyte[])

WebSocketApp
struct WebSocketApp

{WebSocketApp} WebSocket Application (server to accept http-urgrade connections) Constructor: WebSocketApp( strind URI to listen should start with "ws://" on_connect callback: void function ( WebSocket*, void* context ) on_message callback: void function ( WebSocket*, ubyte[], void* context ) void* context ) Methods: start() - start server to listen

WebSocketClient
struct WebSocketClient

{ WebSocketClient } Client class to handle websocket connection Constructor: WebSocketClient ( string URI to connect to, string origin URI to connect from ws_options struct to set options Usage: void onmsg( string msg ){ do_whatever(msg); } c = WebSocketClient("ws://server/path"); while(c.state != ws_state.CLOSED ){ c.poll(); c.dispatch(&onmsg); }

urlparse
struct urlparse

{ urlparse } Simplified regexp-based URL parser Usage: auto u = urlparse("http://server/path?key=val#anchor"); writeln(u.host); writeln(u.toString);

ws_header
struct ws_header

WebSocket message structure