List of all callback defined by LibMqMsgque
The servive-callback have to be a function-pointer of type MqServiceCallbackF (#MQ_TokenF)
There a two different types of callback:
(runtime) void MqConfigSetServerSetup(MQ_CTX const ctx, MqServiceCallbackF fCall, MK_CBP callback)
(runtime) void MqConfigSetServerCleanup(MQ_CTX const ctx, MqServiceCallbackF fCall, MK_CBP callback)
(runtime) void MqConfigSetBgError(MQ_CTX const ctx, MqServiceCallbackF fCall, MK_CBP callback)
(runtime) void MqConfigSetEvent(MQ_CTX const ctx, MqServiceCallbackF fCall, MK_CBP callback)
(runtime) enum MkErrorE MqServiceCreate(MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback)
(runtime) enum MkErrorE MqSendEND_AND_CALLBACK(MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MK_TIME_T const timeout)
(runtime) enum MkErrorE MqSendEND_AND_SUB(MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MK_TIME_T timeout)
Callback used to call a service
Callback used to free a service
Callback used to copy a service
Example from MyServer.c
→ using MqServiceCreate with callback MqServiceCallbackF
#include "common.h" // service to serve all incoming requests for token "HLWO" static enum MkErrorE MyFirstService ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqSendV_E (mqctx, "%s World", MqReadSTR_e(mqctx)); error: return MqSendRETURN(mqctx); } // define a service as link between the token "HLWO" and the callback "MyFirstService" static enum MkErrorE ServerSetup ( MQ_SERVICE_CALL_ARGS ) { return MqServiceCreate(mqctx,"HLWO", MyFirstService, NULL, NULL, NULL); } // package-item enum MkErrorE MyServerFactory ( MQ_CALLBACK_FACTORY_CTOR_ARGS ) { MQ_CTX const mqctx = *contextP = MqContextCreate(NULL,tmpl); MqConfigSetServerSetup (mqctx, ServerSetup, NULL, NULL, NULL); return MK_OK; } // package-main int main (int argc, MK_STRN argv[]) { MqRtSetup_NULL; // setup commandline arguments for later use MK_BFL largv = MkBufferListCreateVC(argc, argv); MQ_CTX mqctx = NULL; // create "MyServer" factory… and make it to the default. MqFactoryDefault( MqFactoryAdd_2(MyServerFactory, "MyServer")); // inspect commandline-argument for the "factory" to choose… and create a object MqFactoryNew_E (MqFactoryGetCalledL(largv), NULL, &mqctx); // start listen for incoming call's MqLinkCreate_E (mqctx, largv); MqCheckForLeftOverArguments_E (mqctx, largv); MqProcessEvent_E (mqctx,MQ_WAIT_FOREVER,MK_TIMEOUT_DEFAULT); error: MkBufferListDelete(largv); MqExit_1(mqctx); }