Please see this link to understand how to write a custom callback. Do pay attention to the inheritance structure.