keep alive/logout functions

Added the ability to include a custom function during the keep alive and
logout requests.