Loading...
Searching...
No Matches
Callback Signature List

List of all callback defined by TclMqMsgque

The callback have to be a Tcl proc or method

There a two different types of callback:

  1. A callback used to define a context
  2. A callback used to define a service

Callback signature

1. The *service-ctx* is the *context* for which the service was defined.
2. If the *callback* is **not** an instance of the calling *context*, the *service-ctx* is added as an argument.
callback-args := service-ctx:MqContextC[in]
[static] proc callback { callback-args ?additional-args...? } ...
[own] ::oo::class create XXX {
superclass MqContextC
method callback { ?additional-args...? } ...
[instance] ::oo::class create YYY {
method callback { callback-args ?additional-args...? } ...
[class] ::oo::class create ZZZ {
self method callback { callback-args ?additional-args...? } ...

There are 4 different types of callback :

type code self argument
procedure ... proc-callback yes
class-method ... [list CLASS callback] yes
instance-method of own class ... callback no
instance-method of other class ... [list INSTANCE callback] yes
1. global or namespace proc
The tcl-proc require an extra argument, the calling context.
proc myCB {ctx} {
$ctx ...
}
...
::oo::class create MyServer {
method serverSetup {} {
my ServiceCreate "MYTO" myCB
...
}
}
2. class method (static)
The class-method require an extra argument, the calling context.
The callback is a list of TWO items, the CLASS and the class-METHOD
The METHOD can be from the CLASS itself or from a superclass of the CLASS or from an other CLASS
::oo::class create MySuper {
self method staticCB {ctx} {
$ctx ...
}
::oo::class create MyServer {
superclass MySuper
method serverSetup {} {
my ServiceCreate "MYTO" [list MyServer staticCB]
...
}
}
3. own instance method (dynamic)
The own-instance-method has NO extra argument
::oo::class create MyServer {
method dynamicCB {} {
my ...
}
method serverSetup {} {
my ServiceCreate "MYTO" myCB
...
}
}
4. other instance method (dynamic)
The other-instance-method require an extra argument, the calling context.
::oo::class create MyOther {
method otherCB {ctx} {
my ...
$ctx ...
}
}
::oo::class create MyServer {
method serverSetup {} {
my ServiceCreate "MYTO" [list $otherCtx myCB]
...
}
}

The ONLY argument of the callback-proc have to be the self object.

Example from MyServer.tcl using MqServiceCreate with instance-callback

package require tclmsgque::MqMsgque
namespace import tclmsgque::MqMsgque::*
namespace import tclmsgque::MkKernel::*

# package-item
::oo::class create MyServer {
  superclass MqContextC

  # service to serve all incoming requests for token "HLWO"
  method myFirstService {} {
    my SendSTART
    my SendSTR "[my ReadSTR] World"
    my SendRETURN
  }

  # define a service as link between the token "HLWO" and the callback "MyFirstService"
  method serverSetup {} {
    my ServiceCreate "HLWO" myFirstService
  }

  # factory startup (constructor)
  constructor {{tmpl ""}} {
    next $tmpl
    my ConfigSetServerSetup serverSetup
  }
} 

# package-main
tclmsgque::MqMsgque Main {

  # setup commandline arguments for later use
  set args  [MkBufferListC CreateLA {*}$argv]

  # create "MyServer" factory... and make it to the default.
  set fct   [[MqFactoryC Add MyServer] Default]

  # inspect commandline-argument for the "factory" to choose... and create a object
  set fct   [MqFactoryC GetCalledL $args]
  set srv   [$fct New]

  try {
    $srv LinkCreate $args
    $srv ProcessEvent MQ_WAIT_FOREVER
  } on error {} {
    $srv ErrorCatch
  } finally {
    $srv Exit
  }
}

Callbacks defined by TclMqMsgque

Global MqSendEND_AND_CALLBACK_RT (MK_RT const mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T const timeout)
MqSendEND_AND_CALLBACK
Global MqSendEND_AND_SUB_RT (MK_RT const mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T timeout)
MqSendEND_AND_SUB
Global MqServiceCreate_RT (MK_RT const mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MkMarkF fMark)
MqServiceCreate
Global MqSetupS::BgError
ConfigApi_IBgError
Global MqSetupS::Event
ConfigApi_IEvent
Global MqSetupS::ServerCleanup
ConfigApi_IServerCleanup
Global MqSetupS::ServerSetup
ConfigApi_IServerSetup