I want to know if it is possible to execute some sort of code upon receive of a registration packet?
It’s possible when using a service listening on AMI-events. This service may check for registration/deregistration events and execute any code You implement within the service.
Yes that is a clever way to do it, but not the most easier. I made something similar on node.js
You will be catching events like
ManagerEvent_ChallengeSent
ManagerEventuccessfulAuth
ManagerEvent_ChallengeResponseFailed
ManagerEvent_Registry