3.7.35. PreClientHook Previous topic Parent topic Child topic Next topic

This optional parameter allows you to define a Perl function that will be called during packet processing. PreClientHook is called for each request before it passed to a Client clause. A reference to the current request is passed as the only argument.
At the time this hook is run, integer attributes have not yet been unpacked and decoded, and encrypted attributes have not yet been decrypted. If you need unpacked, decrypted versions of these attributes, consider using a per-client ClientHook instead.
The hook code is compiled by Perl when Radiator starts up. Compilation errors in your hook code will be reported to the log file at start-up time. Runtime errors in your hook will also be reported to the log file when your hook executes. Multiline hooks (i.e. with trailing backslashes (\)) are parsed by Radiator into one long line. Therefore you should not use trailing comments in your hook.
PreClientHook can be an arbitrarily complicated Perl function, that might run external processes, consult databases, change the contents of the current request or many other things. The current request has its {Client} member set to a pointer to the Client clause handling the request.
# Fake a new attribute into the request
PreClientHook sub { ${$_[0]}->add_attr('test-attr', \