List of all callback defined by TclMqMsgque
The callback have to be a Tcl proc or method …
There a two different types of callback:
- A callback used to define a context
- A callback used to define a service
Callback signature
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::*
::oo::class create MyServer {
superclass MqContextC
method myFirstService {} {
my SendSTART
my SendSTR "[my ReadSTR] World"
my SendRETURN
}
method serverSetup {} {
my ServiceCreate "HLWO" myFirstService
}
constructor {{tmpl ""}} {
next $tmpl
my ConfigSetServerSetup serverSetup
}
}
tclmsgque::MqMsgque Main {
set args [MkBufferListC CreateLA {*}$argv]
set fct [[MqFactoryC Add MyServer] Default]
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